*! version 1.3 27 Jan 2015
help ccmatch (version 1.3)
By Daniel E. Cook www.Danielecook.com

ccmatch

ccmatch -- 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 specify age as a criterion on which to match cases and controls and it will match randomly by age. You can use multiple variables to match based on multiple criteria

ccmatch creates two variables:

match_id gives the id of the partner an individual has been matched to.

matched_pair Numbers pairs starting from one. Pairs will share the same number in this column (see example below).

Syntax

ccmatch variable_list, cc() id()

variable_list -- Specify variables you want each pair to share here.

cc(var) -- Specify the variable you use to identify cases and controls. Must be coded 0=controls, 1=cases.

id(var) -- Specify the variable you to name individuals/observations in your dataset.

Example

match_id matched_pair 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 above output is an example of what match can do. 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().

note I use individual in this document but it could be interchanged with the word 'observation' and meaning would be the same. This program should be used in cases where each row of your dataset constitutes a single individual.

Last Revised 01/27/15
Update - 01/27/15 - Fixed bugs that caused missing values to match.
Update - 03/06/13 - Fixed bugs, reduced number of lines of code.
Update - 12/18/12
- Huge performance improvement - works on extremely large datasets now.

Update - 06/27/12
- Fixed issue where a maximum of only 1600 individuals could be matched.

Initial Release - 12/18/11