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
How to drop the mtitle row in esttab ?In esttab, when I did not specify mtitle, STATA will automatically create a row for title similar to…
help in generating count variableI am working on World Value Survey dataset. It consists of 5 waves and multiple countries in each wa…
Reproducing "estat trendplots" linear-trends modelHello Statalist community, I am doing an analysis using a diff in diff methodology. As I use Stata …
Import multiple CSV filesHi I am trying to import multiple CSV files in a foreach loop. I saved the filenames in the local n…
How to get Durbin-Watson stat in GMM regressions?Dear statalist, I am running GMM regressions with robust HAC matrix and standard errors and I would…
Subscribe to:
Post Comments (Atom)
0 Response to Selecting 3 controls per case
Post a Comment