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]

st: foreach and levels of string variable


From   "Paul O'Brien" <[email protected]>
To   statalist <[email protected]>
Subject   st: foreach and levels of string variable
Date   Mon, 27 Sep 2010 11:28:59 +0100

hi,

i have a dataset with results from a number clinical studies of efficacy of emergency contraception and want to test for trend by day's delay in treatment within each study.

using nick cox's FAQ: Is there a way to tell Stata to try all values of a particular variable in a foreach statement without specifying them?

. 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);

where am i going wrong?



thanks,

paul
*
*   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