On Thu, Mar 26, 2009 at 12:13 PM, Victor M. Enciso M.
<[email protected]> wrote:
Dear all,
I have three vars: soap usage, language and study
language and study can only take two values.
If I want to get the mean of soap usage by language or study I can use
tabstat
tabstat soap usage, by(study)
or if I want a two way table of study and language:
table study language
What I want, and don't know how to get is a two way table of study and
language but instead of having the counts as result I want the mean of soap
usage.
Obviously, stata doesn't accept
tabstat soap usage, by(study language)
So, any suggestions?
Yes, -man tabstat- indicates that one of the Main options is
-statistics(statname [,,,])-
Thus you could...
bysort language: tabstat soap usage, by(study) statistics(mean)
...but you have separate tables for each language.
Other alternatives involve -collapse-ing your data to derive the means
in your sub-groupings and then reshaping and you can then
-outsheet-/-listtex-/-dataout- to the desired format (presumably you
want to put the numbers in some sort of report). Note that -listtex-
and -dataout- are user-written commands available from ssc via -ssc
install [package]-
Yet other alternatives may be possible with the excellent -tabout-
also available from SSC
Neil
--
"The combination of some data and an aching desire for an answer does
not ensure that a reasonable answer can be extracted from a given body
of data." ~ John Tukey (1986), "Sunset salvo". The American
Statistician 40(1).
Email - [email protected]
Website - http://slack.ser.man.ac.uk/
Photos - http://www.flickr.com/photos/slackline/
*
* 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/