Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Order Bar Graph Bars by the Over Variable


From   L S <[email protected]>
To   [email protected]
Subject   st: Order Bar Graph Bars by the Over Variable
Date   Fri, 13 Feb 2009 09:42:45 -0800

Hello,

I am trying to create a simple bar graph in STATA.  Suppose I am using
the sysuse auto dataset.

Q:  I would like to have it so that my graph compares the variables
turn and mpg across the dummy variable foreign.  That is, on the left side
of the graph, it should compare turn across foreign and domestic cars, and
on the right side it should compare mpg across foreign and domestic cars.
Right now I am typing:

sysuse auto, clear
bar graph (mean) turn mpg, over(foreign)

The problem with this is that this displays the mean of turn and mpg for
domestic cars on the left hand side, and then the mean of turn and mpg for
foreign cars on the right hand side.  Visually, this setup makes the reader
compare turn and mpg for domestic cars, and compare turn and mpg for
foreign cars,
instead of the comparison I want.  What I want to essentially do is to
sort the 4 bars by foreign.

graph bar (mean) turn mpg, over(foreign, sort(foreign))

However, this produces an error: "variable foreign not found."

Do you know of any way to make the graph I want?

Thanks a lot.
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index