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   "Clive Nicholas" <[email protected]>
To   [email protected]
Subject   RE: st: RE: bar graph of multiple variables
Date   Mon, 7 Mar 2005 01:18:42 -0000 (GMT)

Scott Merryman replied:

> 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)

Unfortunately, the code broke for me (and I have Roger Newson's -xcontract-):

. clear

. set obs 30
obs was 0, now 30

. qui {

.
. *Create frequency values
. qui {
option idnum() not allowed
r(198);

end of do-file
r(198);

Looking at -whelp xcontract-, there doesn't appear to be an -idnum()- option.

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/



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