Hi,
Using the below sample data, I am trying to obtain the number of values in b1 (id=50_512) that exceed the maximum value of b1 when id=50_511. I would like to do same thing for b2. Given that I have 65 ids in my real data, I was wondering if there is any way to obtain my info of interest using a loop.
Thanks,
Nader
[QUOTE]
clear
// generate example data
set obs 15
set seed 666
gen n=_n
generate b1 = runiform(0,1)
generate b2 = runiform(-50,50)
gen Age_Group=""
replace Age_Group="50_51" if n<6
replace Age_Group="50_51" if n>5 & n<11
replace Age_Group="50_51" if n>10
gen sample_label=.
replace sample_label=1 if n<6
replace sample_label=2 if n>5 & n<11
replace sample_label=3 if n>10
label define sample_label 1 "1.NCG" 2 "2.caregivers<14h/w" 3 "3.caregivers>=14h/w"
label values sample sample
*id is the combination of Age_Group and sample_label
gen id=""
replace id="50_511" if n<6
replace id="50_512" if n>5 & n<11
replace id="50_513" if n>10
Related Posts with Question related to loop/foreach vvv
Time Fixed Effects EsttabDear all, I would like to add a line with the word "Yes" if time fixed effect is used. Unfortunatel…
Latent profile model. Inconsistent mean valueDear Stata users, I am running a latent profile model using the data of a questionnaire addressed to…
many dummies and interaction variables in PPML estimationHello! I am trying to estimate the impact of the Eurasian economic union (EAEU) on bilateral trade f…
Multiple line -if- conditional on variableI have (quite stupidly) have code of this type if market=="a" { replace o=1 replace e=1 replace sta…
Check if two exposure varibales are independent of each otherHi, Apologies if this is very obvious, I've managed to get confused about it. If i want to check if…
Subscribe to:
Post Comments (Atom)
0 Response to Question related to loop/foreach vvv
Post a Comment