Hello, I need to run the loop below separately for each wave of my survey as identified by the interview_nb variable. Since -foreach- does not admit the use of by, my super basic idea was to run each command preceded by -bysort interview_nb- but it does not seem the most efficient way to do that.
Is there a way to run this loop by survey way in a more concise way? Thanks
Code:
ds, has(char deflate) foreach x in `r(varlist)' { g `x'_99pct=`x' g `x'_95pct=`x' g `x'd_99=`x'_d g `x'd_95=`x'_d qui su `x',d replace `x'_99pct=. if `x'>=r(p99)&`x'!=. replace `x'_95pct=. if `x'>=r(p95)&`x'!=. replace `x'd_99=. if `x'>=r(p99)&`x'!=. replace `x'd_95=. if `x'>=r(p95)&`x'!=. }
Comment