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]

# st: AW: Is it possible to create a bar graph with two yvars

 From "Martin Weiss" To Subject st: AW: Is it possible to create a bar graph with two yvars Date Wed, 30 Jun 2010 13:51:24 +0200

```<>

Omit the -stack- option in the second call...

HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von A Loumiotis
Gesendet: Mittwoch, 30. Juni 2010 13:42
An: statalist@hsphsun2.harvard.edu
Betreff: st: Is it possible to create a bar graph with two yvars

Hi,

I use a variation of an example by Nick Cox to ask my question:

clear
set obs 1000
egen id = seq(), block(10)
egen time = seq(), to(10)
format time %tq
gen time2=string(time, "%tq")
gen sector = ceil(3 * runiform())
bysort id: replace sector=sector[1]
label define sector 1 "SECTOR 1" 2 "SECTOR 2" 3 "SECTOR 3"
label values sector sector
gen sales=exp(rnormal())*1000
gen sales2=2*sales
graph bar (sum) sales, over(sector) over(time2,
label(labsize(vsmall))) asyvars stack legend(size(vsmall))
graph bar (sum) sales (sum) sales2, over(sector) over(time2,
label(labsize(vsmall))) asyvars stack legend(size(vsmall))

At the end of the code I'm generating two graph bars.  The first one
has the variable sales as yvar where the bars are stacked by sector
and time is the xvar.
What I would like to do is to generate an analogous graph but with two
yvars instead of one, sales and sales2.  So for each period I would
like to have two bars, one for sales and one for sales2.  However, my
second graph bar command does not achieve this. Is it possible to do
this with graph bar?  If yes, what am I doing wrong?

Thanks a lot,
Antonis Loumiotis
*
*   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/
```

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index