Statalist


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

st: AW: How to label bars with frequency AND percentage for categorical variables?


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: How to label bars with frequency AND percentage for categorical variables?
Date   Tue, 24 Nov 2009 16:13:09 +0100

<> 

The -plot- option to -tabulate- may give you some of the answer:


*************
sysuse auto, clear
foreach var of varlist price rep78 turn{
ta `var', plot
}
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Adam Collins
Gesendet: Dienstag, 24. November 2009 16:06
An: '[email protected]'
Betreff: st: How to label bars with frequency AND percentage for categorical
variables?

Hello, 

I have a series of categorical variables.  For each one, I would like to
create a quick bar graph that displays the count (frequency) of each
category, but also the percentage.

For example, if it was an "hbar" graph, it might look something like this:

__________
          | 10
__________|(33.3%)
_________________
                 | 16
_________________|(53.3%)
____
    | 4
____|(13.3%)


I intend to use a "foreach" loop to iterate through the list of categorical
variables, so I am looking for a solution that can be automated for each
variable in my list.  I don't mind if the solution uses catplot or hbar or
something else.

Any ideas?

Thanks a lot in advance!!

Adam



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


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