Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: graph bar


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: graph bar
Date   Mon, 7 Apr 2008 17:43:04 +0100

My diagnosis resembles David's. It seems you need a restructure first. 

Another way to do it: 

preserve 
collapse X1-X7, by(wave) 
reshape long X, i(wave) 
separate X, by(wave) 
graph bar X?, over(_j) 
restore 

Nick
[email protected] 

David Airey

One solution is to reshape your data so you have wave and time as  
variables.

For example,

clear
set obs 70
egen panel = seq(), from(1) to(2) block(35)
gen id = _n
forvalues i = 1/7 {
	gen x`i' = invnorm(uniform()) + panel
}
reshape long x, i(id) j(time)
graph bar x, over(panel) over(time)

If you just wanted the x1-x7 labeled, you would need to have your data  
organized into two responses by panel, e.g., panel1 and panel2, and  
then issue

graph bar panel1 panel2, over(time)


On Apr 6, 2008, at 10:55 PM, Lloyd Dumont wrote:

> I'm having trouble doing what ought
> to be a simple bar graph.  I have panel data that
> includes some variables along the lines of...
>
> X1 X2 ... X7
>
> I am interested in their means by survey wave for each
> of two waves.  But, in terms of groupings...
> I would like there two be 7 groups, each containing
> two bars--one for wave I and one for wave II.
>
> No matter what I do, it seems to want to create 2
> groups of 7 bars each--the oppposite of what I want.

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