Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: foreach problem


From   "Rajesh Tharyan" <R.Tharyan@exeter.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: foreach problem
Date   Wed, 17 Sep 2008 01:48:03 +0100

Patience is the key.

Sorry, as Michael pointed out mean(abnor'var') should be mean(abnor`var')

Not an excuse for looking carefully enough, but does stata have something
built in to check for this?

Thanks
rajesh

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Rajesh Tharyan
Sent: 17 September 2008 00:32
To: statalist@hsphsun2.harvard.edu
Subject: st: foreach problem 

Hi,

Now,  what could possibly be wrong with this?

foreach var of varlist  deco pico  {
gen abnor`var'=`var'- N`var'
sort d
by d: egen Aabnor`var'=mean(abnor'var')
}

Stata gives me

. abnor'var' invalid name
  r(198);

I have already created N`var' and I can see that it exists..

Thanks
rajesh

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index