Hello everyone. I know a couple of topics have covered this but I can't seem to figure out how to select controls in my dataset. I have an asthma dataset with 200 cases and 4000 controls. I would like to select 3 controls for every case based on a variable labelled time (Give or take 15 days). The problem I have having is that when I conduct the match, I get 300 controls only. I guess I am not sure how to do plus or minus 15 days before getting controls automatically selected and then keeping only 3 controls afterwards. The code I used is below and thank you.
keep if asthma ==0
rename * *_control
rename therapydate_control therapydate
tempfile controls
save `controls'
keep if asthma ==1
rename * *_case
rename therapydate_case therapydate
joinby time using control, unmatched(master)
set seed 5678
gen double shuffle = runiform()
by id (shuffle), sort: keep if _n <= 3
drop shuffle
Related Posts with Selecting 3 controls per case
OLS/Random Effects/Mundlak Interaction termHi, I am currently using a panel data-set to identify ethnic pay differentials. My dependent variabl…
Interpreting "estat vce, corr" output -- post-estimation of menbreg with random slope and interceptHi everyone, I am interested in getting some assistance interpreting the output of a estat vce, corr…
Categorizing ICD-10 codes into major categoriesHi; I work with ICD-10 codes regularly. I'm currently involved in a project where several thousand …
Extrac the numbers in variable labelsHi, How can I extract the numeric part from my variable labels? For example: I have the next var …
Is this a bug?I have Stata SE 15.1 and I noticed Stata does not convert 2/29/2011 to a date value. When I run: C…
Subscribe to:
Post Comments (Atom)
0 Response to Selecting 3 controls per case
Post a Comment