Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Better way to -graph- -tabulate varname1 varname2, column nofreq- (can't find better way in manual)


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Better way to -graph- -tabulate varname1 varname2, column nofreq- (can't find better way in manual)
Date   Mon, 5 Jan 2004 12:34:13 -0000

There's a user-written program here that may help. 

. ssc inst catplot 
. catplot bar happy agebin, asyvars

Nick 
[email protected] 

Renzo Comolli
> 
> I am a newbie as far as graphing is concerned. I read (what seems
> appropriate of) the [G] manual and I found a way to do what 
> I want, but it
> is quite cumbersome. I believe there must be a better way. 
> I would be
> grateful for any suggestion, or just the page in the manual.
> 
> Here is a (made up) example
> . webuse gss1991
> . gen agebin=int(age/10)
> . tab happy agebin, colum nofreq
> 
> 
>       general |                                         agebin
>     happiness |         1          2          3          4  
>         5
> 6          7          8 |     Total
> --------------+---------------------------------------------
> ----------------
> ---------------------------+----------
>    very happy |      9.09      27.24      30.37      32.97  
>     30.06
> 35.50      33.11      34.92 |     31.09 
>  pretty happy |     90.91      63.79      58.12      53.62  
>     60.12
> 54.44      54.73      55.56 |     57.99 
> not too happy |      0.00       8.97      11.52      13.41  
>      9.82
> 10.06      12.16       9.52 |     10.92 
> --------------+---------------------------------------------
> ----------------
> ---------------------------+----------
>         Total |    100.00     100.00     100.00     100.00  
>    100.00
> 100.00     100.00     100.00 |    100.00 
> 
> 
> I would like a graph with agebin as X variable and each 
> "very happy",
> "pretty happy", "not too happy" as different Y variables.
> 
> >From the [G] manual I gather that if "very happy", "pretty 
> happy", "not too
> happy" were different variables, then I could just do
> 
> . graph twoway line very_happy pretty_happy not_too_happy agebin
> 
> Is there a way to obtain the same result without having to 
> actually go and
> create the table as a dataset with very_happy pretty_happy 
> not_too_happy
> agebin as variables?

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