Statalist The Stata Listserver

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

RE: st: creating bar charts

From   "Nick Cox" <>
To   <>
Subject   RE: st: creating bar charts
Date   Sun, 26 Mar 2006 18:19:16 +0100

I answered the previous questions on Friday. 

. graph bar (asis) SexRatio if race==1 SexRatio if race==2, over(age)

is just illegal, as you can't have two separate -if- conditions
and you can't split a variable list with an -if- condition. 
So it violates the syntax specified in the help. 

A more interesting point is that the problems Scott compares
are not of the same form. 

Every station has a January and a July temperature in the 
dataset referred to. But every group is one race or the other, and not both. 

You could see your way to separate variables easily by using -separate-; 
that's what -separate- is for. But I still don't think -graph bar- would cough up
as it is expecting a different data structure. 

The underlying issue is that -graph bar- is not as general as users would 
like it to be. You'd think that it was a way of drawing every bar graph 
known to man, woman or cyborg. Ha! Wrong. As has often been stressed on 
this list, there can come a point when you need to back out and try -twoway 
bar- instead. That really is pretty much as general as you would like to be. 

-textbarplot- recently posted on SSC offers an easy wrapper for that. 


> Tacking this question onto my previous ones - in the help 
> sections, I  
> notice that what I'm attempting to do is done because the variables  
> to be mapped onto the graph are actually different values.  For  
> instance, in this code:
> . graph bar (mean) tempjuly tempjan, over(region)
> This is from the help on -graph bar- from a datafile called - 
> citytemp-.  This produces exactly what I'm trying to do, where  
> "region" in my case is "age", and the two variables side by side for  
> each period are the white and black sex ratio.  But, my data usually  
> is coded 1 or 2 for race, and not actually separate variables  
> altogether for race.  In other words, if I had a variable called  
> "bsr" for black sex ratio and "wsr" for white, then it'd be  
> straightforward to reproduce the above as:
> . graph bar (asis) wsr bsr, over(age)
> But how do I accomplish the above if I use one variable (called  
> "sexratio") which takes on two values (1 or 2 for white or black),  
> and I wish to graph the white and black sex ratios side by side.   
> When I do this:
> . graph bar (asis) SexRatio if race==1 SexRatio if race==2, over(age)
> I get an error that says, "invalid 'SexRatio' "

*   For searches and help try:

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