I would like to match cases and controls. I have got a variable saved as case where 1=case and 0=control. I have 168 cases and 860 controls. Hoping to match 1:5. I want to match on gender and age. The age range in my sample is 7 years, 8 months and 10 years 6 months.
Have tried the following code with just matching for gender as I am not sure how to write in matching for age as well... I do not get any errors in it, however it does not seem to work as at the end my case variable has disappeared and I am left with no variables relating to the matched cases and controls.
Code:
use "C:\Users\jtuckles\Downloads\dataset.dta", clear preserve keep if case drop case tempfile cases save `cases' restore drop if case drop case ds cdgender, not rename (`r(varlist)') =_ctrl tempfile controls save `controls' use `cases' joinby cdgender using `controls', unmatched(master) set seed 8846 gen double shuffle = runiform() duplicates drop by uniqueid (shuffle), sort: keep if _n <= 5 drop shuffle
0 Response to Matching cases and controls 1:5
Post a Comment