Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: bar graph of multiple variables


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: bar graph of multiple variables
Date   Sun, 6 Mar 2005 17:35:40 -0600

Ok, how about something like this:

*Create data set: 7 variables with values {1, 2, 3}
clear
set obs 30
qui {
forv i = 1/7 {
	gen c`i' = 1
	replace c`i' = 2 if uniform() <.4
	replace c`i' = 3 if uniform() <.3
}
}

*Create frequency values
qui {
forv i = 1/7 {
	tempfile file`i'
	xcontract c`i', freq(freq) idnum(`i')  saving(`file`i'')
}
}

dsconcat `file1' `file2' `file3' `file4' `file5' `file6' `file7'
drop c*
egen id2 = fill(1 2 3 1 2 3)

forv i = 1/7 {
	local relabel  `relabel' `i' C`i'
}

graph bar freq, over(id2) over(idnum, relabel( `relabel')) ytitle(Frequency)


Scott


> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Clive Nicholas
> Sent: Sunday, March 06, 2005 1:59 PM
> To: [email protected]
> Subject: Re: st: RE: bar graph of multiple variables
> 
> Scott Merryman replied to Richard Sherman:
> 
> > How about something like this:
> >
> > sysuse auto
> >
> > graph bar (count) mpg, over(rep) over(fore)
> 
> Another way to get closer to what Richard requires would be to use Nick
> Cox's -catplot- routine, downloadable via SSC. Using this would allow him
> to do something like:
> 
> . catplot bar continuousvar, over(discretevar) sort percent asyvars
> 
> But even this doesn't quite do what Richard wants, which is to bar-graph
> seven _individual_ variables which all have (presumably) the same three
> categories _without_ having to specify an -over()- option. Like Richard, I
> couldn't quite crack it.
> 
> CLIVE NICHOLAS        |t: 0(044)7903 397793
> Politics              |e: [email protected]
> Newcastle University  |http://www.ncl.ac.uk/geps
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index