Greetings,
In the above code for rangejoin, if I want to do 1:4 matching (1 case and 4 controls) what do I have to do? I did the following to create 1:1 matching. In the following code, in the highlighted text, if I do by id (shuffle), sort: keep if _n < 5, will that give me 1:4 matchung? thanks.
preserve
keep if Group == 0
tempfile controls
save `controls'
restore
keep if Group ==1
rangejoin age -10 10 using `controls', by(Sex)
set seed 1234
gen double shuffle = runiform()
by id (shuffle), sort: keep if _n == 1
drop shuffle
In the above code for rangejoin, if I want to do 1:4 matching (1 case and 4 controls) what do I have to do? I did the following to create 1:1 matching. In the following code, in the highlighted text, if I do by id (shuffle), sort: keep if _n < 5, will that give me 1:4 matchung? thanks.
preserve
keep if Group == 0
tempfile controls
save `controls'
restore
keep if Group ==1
rangejoin age -10 10 using `controls', by(Sex)
set seed 1234
gen double shuffle = runiform()
by id (shuffle), sort: keep if _n == 1
drop shuffle
Comment