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
Command collapse AND keeping the original datasetDear all, I was just thinking about this: When you analyze hierarchical structured dataset (for exa…
RIF regression and decomposition of income inequalityI need help to have the command which is used in this paper of Rios Avila (2019) to have the results…
How to use categorical variable in dynamic panel regression?Hello, I am using a country variable, called "targetcountry" in my dynamic panel regression. This v…
How to interpret the outcome of command “gllamm”?Dear statalists, I have gotten the outcome of “gllamm”,but I don't know how to illustrate,could you …
putexcel for multiple tables extending beyond Excel column ZI recently found myself with need to produce over 1000 cross-tabulations with their respective chi-s…
Subscribe to:
Post Comments (Atom)
0 Response to Selecting 3 controls per case
Post a Comment