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
Effect of varying number of integration points on model fit for melogitHi everyone, I am using meologit to fit a model to individual binary outcome data from a cluster ra…
OLS vs logistic regression*Hello, I was hoping someone could clarify this for me. I have used OLS regressions using the PISA d…
The problem with rcallThe package rcall is great! But when I start, I encounter a problem. When I transfor a scalar to R, …
How to perform an equivalence test (based on a t-test) for regression coefficients?Hi, How do I perform an equivalence test (based on a t-test) for regression coefficients in STATA? …
ttest code multiple variables that define groupHello. I cant seem to work out the coding that replicates the following function, which when copied …
Subscribe to:
Post Comments (Atom)
0 Response to Looping using forvalue in winsor2
Post a Comment