forvalues x in 1/28 {
is not legal. Try
forvalues x = 1/28 {
Nick
[email protected]
Doogar, Rajib
> 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?
*
* 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/