I am using the following command in Stata 14.2 which has data stacked by industry-year wise. There are 357 industry year groups for the groups 1 to 271 I used the following syntax :
. forval i = 1/271 {
2. capture {
3. winsor cfo_sc if group == `i', gen(work) h(1)
4. replace cfo_sc_w = work if group == `i'
5. drop work
6. }
7. }
This worked fine for winsorizing the data first 271 groups but when I am using the following syntax for winsorizing the remaining groups, I get the winsorised values for group 272 only for other groups I get blank cells. further temporary variable cfo_sc_t created also do not get dropped.:
forval i = 272/357 {
2. capture {
3. winsor2 cfo_sc if group == `i', suffix(_t) cuts(1,99)
4. replace cfo_sc_s = cfo_sc_t if group == `i'
5. drop cfo_sc_t
6. }
7. }
Kindly guide what's wrong in the syntax.
Thank you.
Related Posts with Looping using forvalue in winsor2
using not allowed stata imputation hotdeckvarHi, I have a problem with my imputing syntaxs. hotdeckvar pasajeros1 using p, store by(marca clase2…
How to adjust restricted cubic spline curve for custom references?Hi, I am currently learning on how to conduct a dose-response meta-analysis. Following estimations …
How to make of use loop in this caseDear all, I would like to seek your advice on the use of loop or other equivalent functions. My dat…
Travel cost method combining RP and SPHi I have a dataset with info on #trips for each individual (a total of 200) to a particular recreat…
Determine the appropriate lag of independent variable panel data fixed effect modelHi, I am doing a fixed effect panel data regression (T=40 N=1087). Theoretically my independent va…
Subscribe to:
Post Comments (Atom)
0 Response to Looping using forvalue in winsor2
Post a Comment