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 cases and controls.
Installation
ssc install ccmatch
Syntax
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.id( )
(optional) Specify a variable you use as an ID and thematch_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).
Example
match_id | match | name | case_control | age |
---|---|---|---|---|
a6 | 1 | a2 | 0 | 15 |
a2 | 1 | a6 | 1 | 15 |
a7 | 2 | a4 | 0 | 16 |
a4 | 2 | a7 | 1 | 16 |
a8 | 3 | a5 | 0 | 17 |
a5 | 3 | a8 | 1 | 17 |
a10 | 4 | a1 | 0 | 19 |
a1 | 4 | a10 | 1 | 19 |
. | a3 | 0 | 15 | |
. | a9 | 1 | 18 |
The table above shows example ccmatch output. 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 case/controls 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( )
.