Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: catplot showing not chosen categories in x-axis


From   Eric Booth <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: catplot showing not chosen categories in x-axis
Date   Wed, 25 Aug 2010 20:10:06 +0000

<>

Jorg:

The value "2" and it's label "other" are never "chosen categories" as far as -catplot-, and Stata for that matter, are concerned. 
It's important to realize that adding a label for the value "2" where there is never actually a value of "2" for the variable (foreign) does not change the summary statistics for that variable.  

There's likely a better solution than this, but you could add a new observation with the value "2" for foreign to a very large dataset where that new observation will account for <.1% of the data, so it looks like "other" has a 0% label.  You could temporarily -expand- the dataset and the relative percentages each category would remain the same as the unexpanded data (but be aware of what you are doing here and what it is doing to your data):

***********!
sysuse auto, clear
label define origin  2 "other", add
label li origin
ta for, miss
catplot  foreign, recast(bar) percent blabel(bar, position(outside) format(%5.1f) ///
size(medium) color(red) ) ytitle(Prozent) ylabel(0(10)100, labsize(small))

	preserve
expand 1000
set obs `=_N+1'
replace for = 2 in `=_N'
ta for, miss
catplot  foreign, recast(bar) percent blabel(bar, position(outside) format(%5.1f) ///
size(medium) color(red) ) ytitle(Prozent) ylabel(0(10)100, labsize(small))
	restore
***********!

Also, it's worth mentioning that -catplot- is a user-written package by NJC available from SSC.

~ Eric

__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754



On Aug 25, 2010, at 2:23 PM, Jörg Eulenberger wrote:

> 
> i am looking for an possibility in catplot to show all (not only the chosen one) categories of labelset in the x-axis.
> 
> sysuse auto
> label define origin  2 "other", add
> label list origin
> catplot  foreign, recast(bar) percent blabel(bar, position(outside) format(%5.1f) size(medium) color(red) ) ytitle(Prozent) ylabel(0(10)100, labsize(small))
> 
> In the example i want in the x axis the new third category with zero percent.
> Any ideas?




*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index