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
-coefplot- for treatment effectsHello, I ran treatment effects regression adjustment (-teffects ra-, pomeans aequations) and now I …
Creating a new variable with date and time togetherHi, I am trying to create a new variable that has the date (bedtime_date) and time (q4_time_outofbe…
Replicating xtabond2 results with xtdpdgmmHello, I am using the following two-step difference GMM model: Code: xtabond2 y l.y l.x1 l.x2 l.x3…
All coefficients insignificantI am a bit of a beginner when it comes to stata, I am using the program to create a fixed effects mo…
Latent class analysis: marginal predicted probabilities vs marginal predicted posterior probabilities and estat vs predictI have a latent class model that I'm broadly happy with. I want to be able to say that x% of the sam…
Subscribe to:
Post Comments (Atom)
0 Response to Selecting 3 controls per case
Post a Comment