Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: collecting tabulate results |
Date | Tue, 8 Feb 2011 18:31:26 +0000 |
You can do this in Stata in various ways. Here is one. -tabm- from the -tab_chi- package on SSC has a -replace- option that overwrites the data in memory with a dataset containing the data for this graph. In this script I create a small dataset and then push it through -tabm-. I just found out that -graph- does not like the name _values used by -tabm-, so I changed it. clear set obs 100 local i = 1 foreach v in a b c d e f g h { gen `v' = runiform() < `i'/10 local ++i } tabm a-h, replace rename _values values label def values 0 no 1 yes label val values values graph bar (mean) values, over(_stack) ytitle(fraction using) Nick On Tue, Feb 8, 2011 at 5:46 PM, Broudy, David, DOH <David.Broudy1@state.nm.us> wrote: > In a survey, we asked which hospital services respondents had used: > Dental > Diabetes > Mental Health...there are a total of 9 services > For each service, we asked a separate question with answers 1=yes, 0=no. > We would like to make a bar graph showing the number and percentage of "yes" responses for each service (variables are named N8A-N8I) > > Of course, I can run tabulate nine times, record the number of "yes" answers to each question, enter this into Excel, and use this to make the bar graph. > > Is there a way to collect the positive responses to a series of tabulates and use those with graph? > > When I do this manually, I make a file the looks like this: > Prgm, freq, pct, n > Dent,39, 30.7,127 > DB,71,55.0,129 > MH,106, 82.8,128... > Then: graph bar freq, over(prgm, sort(1)) etc > > We have quite a number of questions formatted like this, so an alternative to doing it manually would be helpful. * * 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/