Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: foreach help

From   Tina Hernandez-Boussard <>
Subject   st: foreach help
Date   Tue, 18 Dec 2012 10:37:37 -0800

HI All,

I was hoping that someone might help me trouble shoot my foreach loop.  Seems very simple, yet I keep getting an error.  My code is:

. levelsof category , local(levels)
`"allergies"' `"assessment and plan"' `"history of present illness"' `"laboratory results"' `"medications"' `"past medical history
> "' `"physical exam"' `"plan"' `"social history"'

. foreach 1 of local levels {
  2. sum(nonlmct ) if category ==`1'
  3. di r(sum)
  4. }
allergies not found

Yet if I run this code outside of the loop I get an the below:

. sum(nonlmct ) if category =="allergies"

    Variable |       Obs        Mean    Std. Dev.       Min        Max
     nonlmct |        72         4.5    2.897303          2         12

. di r(sum)

Any help??


*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index