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
collapse variable in more than 1 way in one collapse commandIs it possible to collapse the same variable in more than 1 way in 1 collapse command (e.g., to get …
How to generate i*j by forvalues?If year=1,2,3,4; and prov=1,2,3,4,5,6,7. So how to calculate i*j, thanks a lot! I run this,but it is…
Help Regarding "esttab"Greetings Everyone! Hopefully, you will be fine, I want to add Groups(Firms) in the Regression Tabl…
Place date year on a second line on x-axisMy x-axis data is currently in date (week) format, so my current code as part of a twoway graph is a…
collapse variable in more than 1 way in one collapse commandIs it possible to collapse the same variable in more than 1 way in 1 collapse command (e.g., to get …
Subscribe to:
Post Comments (Atom)
0 Response to Question related to loop/foreach vvv
Post a Comment