December 19, 2012   

ccmatch is used to randomly match cases and controls based on specified criteria. For instance, if you wanted to randomly match cases and controls based on age, you can use ccmatch to pair up people with the same age. You can use multiple variables to match based on multiple criteria.


ssc install ccmatch


ccmatch variable_list, cc( ) [id( )]

*specifying an id is optional

  • variable_list The variable list are categorical or discrete variables you want to match on (example: age, sex, weight class, etc.).
  • cc( ) Specify your case control variable here. 0=control; 1=case makes the most sense to me but it could be the reverse as well.
  • id( ) (optional) Specify a variable you use as an ID and the match_id variable will be created and list the case/control partner.

ccmatch creates one to two variables:

  • match – an integer shared by a case and control.
  • match_id – Optional – the ID partner of the case control pair (specified in a separate variable).


match_id match name case_control age
a6 1 a2 15
a2 1 a6 1 15
a7 2 a4 16
a4 2 a7 1 16
a8 3 a5 17
a5 3 a8 1 17
a10 4 a1 19
a1 4 a10 1 19
. a3 15
. a9 1 18

The above output is an example of what match can do. The highlighted variables were created by ccmatch. The original data (name, case_control, age) is unchanged, except that it has been reordered. The command used was:

ccmatch age, id(name) cc(case_control)

Age was specified following ccmatch to indicate that we wanted to match cases/control who are the same age.

The case/control variable is specified as an option using cc( ), and the id of each individual is specified using id( ).

STATA Programs