Dear List
I have a dataset of participants and reference individuals.
As an example the data is:
case 0/1
sex 0/1
age integer in whole years
i found this old post in the old forum se link below.
That describe how to match 2:1 by age using the following example.
now i don't have an exact match, and would like to match by sex and age±3 years.
I would prefer it so that i did not need to use the same control for mere than one case.
can anyone tell me how to do that, preferably with an indicator of what case is matched to what two controls.
Thank you.
Lars
I have a dataset of participants and reference individuals.
As an example the data is:
case 0/1
sex 0/1
age integer in whole years
i found this old post in the old forum se link below.
That describe how to match 2:1 by age using the following example.
Code:
clear // mock up control data set seed 846 set obs 500 // don't know how many controls you have gen byte case = 0 gen byte age = 20 +ceil(65*runiform()) // broad age range assumed tempfile controls sort age save `controls' clear // mock up cases set obs 63 gen byte case = 1 gen byte age = 20 +ceil(65*runiform()) //The real stuff starts here; you have an existing control file you can append to your cases. append using `controls' gen rand = runiform() sort age case rand by age: egen ncases = sum(case) keep if (ncases >=1) // age groups with no cases are irrelevant // The following keeps the first 2 controls for each case within each age group by age: keep if (case ==1) | ((_n <= 2*ncases) & (case == 0)) tab2 age case by age: egen ncontrols = sum(case == 0) count if (ncontrols < 2*ncases)
I would prefer it so that i did not need to use the same control for mere than one case.
can anyone tell me how to do that, preferably with an indicator of what case is matched to what two controls.
Thank you.
Lars
Comment