Statalist


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

RE: st: RE: frequency bar charts of string variables


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: frequency bar charts of string variables
Date   Wed, 22 Jul 2009 18:00:56 +0100

Note also that this works 

. graph hbar (count) foreign, over(Foreign) ytitle(frequency)

But not this: 

. graph hbar (count) Foreign, over(Foreign) ytitle(frequency)
Foreign may not be both target and by()
r(198);

The awkwardness here was the main reason for writing -catplot-. 

Nick 
n.j.cox@durham.ac.uk 


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Florian
Wakolbinger
Sent: 22 July 2009 17:56
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: frequency bar charts of string variables

thx, this is very helpful
Florian

Nick Cox schrieb:
> There are commands to do this, which I presume is what you want. In
> official Stata it is not too difficult. First read in suitable data 
>
> . sysuse auto
> (1978 Automobile Data)
>
> Suppose that -foreign- were a string variable, which we can simulate
> with 
>
> . decode foreign, gen(Foreign)
>
> Now go 
>
> . gen one = 1
>
> . graph hbar (sum) one, over(Foreign) ytitle(frequency)
>
> However, the user-written command -catplot- from SSC may prove more
> convenient. 
>
> . catplot hbar Foreign
>
> For -hbar- read also -bar-, for vertical versions usually more
difficult
> to read. 
>
> Nick 
> n.j.cox@durham.ac.uk 
>
> Florian Wakolbinger
>
> is there an option in stata to draw bar charts of string variables,
i.e.
>
> if the variable contains 40 "yes" and 60 "no", to draw a chart with
two 
> bars of height 40 and 60?
>
> to put it differently, is there an option to visualize the results of 
> the command tab varname


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index