Hi all,
I am trying to create a new indicator variable based on whether an individual is in the top 5th percentile across age. Here is what I have so far - struggles to create new variable based on the minimum value stored a local 95th percentile.
Many thanks in advance for any help on this.
Kind regards,
Michelle
local VARS height age bmi
local RACE2 white black other
foreach var of local VARS {
foreach race2 of local RACE2 {
summarize `var' if race2 == "`race2'", d
local p95 `r(p95)'
dis "for variable `var' & race2 == `race2'; p95 = `r(p95)', mean (SD) = `r(mean)' (`r(sd)')
}
foreach var of local VARS
gen `var'_group = 1 if `var' >= `p95' & `var' < .
replace `var'_group = 0 if `var' < `p95'
}
}
Related Posts with Saving & using multiple scalars to generate new variables
offset variable in panel data GEEHi, stata users I want some explanation about "offset variable" My dataset below is a unbalanced pa…
rolling monthly (fixed window) stats via Rangestat (SSC)Hi there, I am trying to calculate the rolling standard deviation, skewness and kurtosis via Rangest…
Drop countries which do not have at least three firms in each yearHi all, I have a cross-country panel dataset with multiple countries and firms over the sample peri…
Unable to run xtcsd, pesaranI'm using a panel data set that is unbalanced. I'm running through tests for OLS assumptions and my …
Diagnostics test in Panel Data AnalysisHi everyone! I am doing my master thesis using panel data regression. However, before proceeding to…
Subscribe to:
Post Comments (Atom)
0 Response to Saving & using multiple scalars to generate new variables
Post a Comment