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: mean and SD by categories


From   "Dherani, Mukesh" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: mean and SD by categories
Date   Tue, 16 Jul 2013 11:43:34 +0000

Dear all,
I am very novice in programming. 
I have a dataset with BMI by three categorical variables age (7 groups), sex (2 groups) and SES (5 groups).  I was to generate a line graph showing mean BMI with 95%CI by age , sex  and SES.  Below is my code to create local that I want to use in twoway line graph:

forval a=1/2 {
forval b=1/7 {
forval c=1/5  { 
sum bmi if sex==`a' & agegp==`b' & ses==`c'
local mean`a'`b'`c'=r(mean)
local sd`a'`b'`c'=r(sd)
local up`a'`b'`c'=r(mean)+(1.96*r(sd))
local lo`a'`b'`c'=r(mean)-(1.96*r(sd))
di mean`a'`b'`c' sd`a'`b'`c' up`a'`b'`c' lo`a'`b'`c'
}
}
}


At the end of this command stata says mean111 was not found! 
Secondly, I want graph to show me mean bmi (y axis) and age (x axis) for each ses for each sex separately. Should I carry this out in the loop or outside the loop?

Any help is highly appreciated.  

BW,m


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


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