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]
Re: st: collecting tabulate results
From
Eric Booth <[email protected]>
To
"<[email protected]>" <[email protected]>
Subject
Re: st: collecting tabulate results
Date
Tue, 8 Feb 2011 18:20:20 +0000
<>
Here's 2 options to consider:
**************************!
**Watch for wrappping-->
//create fake dataset//
clear
set obs 900
foreach a in A B C D E F G H I {
loc r .45
if inlist("`a'", "A", "C", "D", "F") loc r .8
g N8`a' = rbinomial(1, `r')
}
*********
**1.
//percent of Pos. Responses//
graph bar (mean) N8* , blabel(bar) ///
name(g1, replace) title(Program %)
//freq of Pos. Responses//
preserve
recode N8* (0=.)
graph bar (count) N8* , blabel(bar) ///
name(g2, replace) title(Program Freq)
restore
gr combine g1 g2
**2.
//create graph from summary dataset//
loc d _N //captures the total N for calc
preserve
ds
collapse (sum) `r(varlist)'
xpose, clear varname
rename _varname prgm
rename v1 freq
g pct = freq/`d'
foreach v in freq pct {
graph bar (asis) `v', over(prgm, sort(1)) ///
title(`v') name(g`v', replace) blabel(bar)
loc clist g`v' `clist'
}
gr combine `clist'
restore
**************************!
- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754
On Feb 8, 2011, at 11:46 AM, Broudy, David, DOH 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.
>
> Thank you,
>
> David
> NM Dept Health
>
>
>
> *
> * 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/
*
* 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/