the syntax of -forvalues- is not correct.
-help forvalues- reveals that you should use "=" instead of "in"
forvalues x = 1/28 {
...
}
2006/2/8, Doogar, Rajib <[email protected]>:
> Dear List
>
> Can someone please tell me why the following code produces an "Invalid
> Syntax r(198)" error and how to fix it?
> ===
> gen newvar=0 if oldvar ~=.
> forvalues x in 1/28 {
> quietly summ oldvar if myvar==`x', det
> replace newvar=1 if (oldvar < r(p1) | oldvar > r(p99)) & myvar==`x'
> }
> ===
> I am running Stata/SE 8.2 for Windows.
>
> In case this helps, I have tried manually typing in:
> ===
> gen newvar=0 if oldvar ~=.
> quietly summ oldvar if myvar==1, det
> replace newvar=1 if (oldvar < r(p1) | oldvar > r(p99)) & myvar==1
> quietly summ oldvar if myvar==2, det
> replace newvar=1 if (oldvar < r(p1) | oldvar > r(p99)) & myvar==2
> etc...
> ===
> and I get the desired outcome, but when I run the forvalues loop, things
> crash. What am I doing wrong?
>
> Many thanks!
>
> r.
>
> Rajib Doogar,
> Department of Accountancy,
> The University of Illinois at Urbana-Champaign
> 1206 S. Sixth Street, Champaign, IL 61820
> Ph: 217.244.8083, Fax: 217.244.0902
> http://www.cba.uiuc.edu/doogar
>
>
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/