Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

AW: st: WG: Present n in graphs


From   "Kaulisch, Marc" <kaulisch@forschungsinfo.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: st: WG: Present n in graphs
Date   Mon, 16 May 2011 10:27:36 +0200

Hi Eric,

Thanks a lot this works great. I tested it with my own data and graphs...

Marc 

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Eric Booth
Gesendet: Montag, 16. Mai 2011 10:12
An: <statalist@hsphsun2.harvard.edu>
Betreff: Re: st: WG: Present n in graphs

<>
Hi Marc:

Here's an example:
**************!
sysuse auto, clear
graph hbox mpg, over(foreign)

levelsof for, loc(ll)
foreach v in `ll' {
qui su for if for==`v', d
loc nn = `r(N)'
lab	def origin `v' `"`:lab origin `v'' (n = `nn')"', modify
}
lab li
qui su for, d
graph hbox mpg, over(foreign) note(total n = `r(N)') **************!
Also, there are more detailed examples/tips on my site:  http://goo.gl/nYAMl

- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
ebooth@ppri.tamu.edu
Office: +979.845.6754


On May 16, 2011, at 2:59 AM, Kaulisch, Marc wrote:

> Does anybody know if there is an elegant way to present the number of 
> cases represented in a graph automatically?
> 
> sysuse auto
> graph hbox mpg, over(foreign)
> 
> Now I would like to add the count number of nonmissing cases of each 
> foreign category into the graph either to the labels or the boxplots, 
> bars etc.
> Of course I could do it manually, but I would like to know a more 
> automatic way.
> 
> In tabplot (ssc), I find a showval-option that looks similar to what I 
> need, but I would like to use such an option in other types of graphs.
> Nick, if I may express a wish: maybe if possible a showval-option 
> would be a good addon to your -catplot- and -statplot- programs (both 
> ssc) ;-) Or have I missed something?
> 
> Thanks for your helping comments.
> 
> Marc
> 
> *
> *   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/

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