Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "paul o'brien" <paul.obrien@afe2.org.uk> |
To | statalist <statalist@hsphsun2.harvard.edu> |
Subject | st: foreach and levels of string variable |
Date | Mon, 27 Sep 2010 22:03:00 +0100 |
thanks martin and neil with the advice on adding quotes. however, i still get the same error: . levelsof study, local(levelstud) `"Ashok 2002"' `"Creinin 2006"' `"Ellertson 2003"' `"Fine 2010"' `"Glasier 2010"' `"Hamoda 2004"' `"Ho&Kwan 1993"' `"WHO 19 > 98"' `"von Hertzen 2002"' . foreach l of local levelstud { 2. ptrend p1 np1 day if study == "`l'" 3. } Ashok not found r(111); removed " 2002" in "Ashok 2002" and others - same problem. paul On 27 September 2010 11:42, Maarten buis <maartenbuis@yahoo.co.uk> wrote: > > --- On Mon, 27/9/10, Paul O'Brien wrote: > > . levelsof study, local(levelstud) > > > > . foreach l of local levelstud { > > 2. ptrend p1 np1 day if study == `l' > > 3. } > > Ashok not found > > r(111); > > > > where am i going wrong? > > ptrend p1 np1 day if study == `l' > > should be > > ptrend p1 np1 day if study == "`l'" > > hope this helps, > Maarten > > -------------------------- > Maarten L. Buis > Institut fuer Soziologie > Universitaet Tuebingen > Wilhelmstrasse 36 > 72074 Tuebingen > Germany > > http://www.maartenbuis.nl > -------------------------- > > > > > * > * 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/