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
multiple regression with interaction effect, but which variables should interact?Hi there, I've been searching for an answer on the internet but I haven't found anything clear yet.…
Imputing Data ProcedureHello Statlister, I have a panel dataset with 15 years of consecutive data, however I have one crit…
Within .ado files, is there a way to restore data but keep, until the end of program, tempvars created by the program?Dear All, I have a somewhat involved problem, but I think it boils down to this. I'm writing a progr…
keep variables using predict after multiple regressionsI am aware that after regress, I can use predict to generate a new predicted value. But how can I do…
Assumptions testing - ITSAHello, I'm running some single time series using ITSA. Are pperron and swilk appropriate assumption…
Subscribe to:
Post Comments (Atom)
0 Response to Looping using forvalue in winsor2
Post a Comment