Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: foreach and levels of string variable


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: foreach and levels of string variable
Date   Tue, 28 Sep 2010 07:56:49 +0000 (GMT)

--- On Mon, 27/9/10, paul o'brien wrote:
> however, i still get the same error:
> 
> . levelsof study, local(levelstud)
> 
> . 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.

I tried to reproduce your error, but I can't. It just should
work. This is what I tried:

*------------ begin example -------------
drop _all
input str16 study
`"Ashok 2002"' 
`"Creinin 2006"' 
`"Ellertson 2003"' 
`"Fine 2010"'
`"Glasier 2010"' 
`"Hamoda 2004"' 
`"Ho&Kwan 1993"' 
`"WHO 1998"' 
`"von Hertzen 2002"'
end

levelsof study, local(levelstud)
foreach l of local levelstud {
	tab study if study == "`l'"
}
*-------------- end example --------------

Maybe you should contact Stata's tech support, as you can
sent them the data and your .do file. That way they can 
exactly see what is going on. See:
<http://www.stata.com/support/tech-support/>

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index