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]
st: Suppress unused values of categorical var in graph? (Stata 11)
From
"Kaulisch, Marc" <[email protected]>
To
<[email protected]>
Subject
st: Suppress unused values of categorical var in graph? (Stata 11)
Date
Sun, 14 Aug 2011 14:02:42 +0200
I came across a problem with -ciplot- (from ssc) because option
ytitle("") does not suppress the ytitle. As Nick Cox (author of ciplot)
mentioned earlier that he does not touch ciplot anymore and one should
use the statsby strategy (see Stata Journal 10, 1, p.143-151). I started
to follow his advise but come to a point of dissatification and maybe
some one can help me (still Stata 11 user).
I have a categorical variable with categories ranging from 8 to 44 where
some values in this range are not attached to any categories. Drawing a
graph means that on the axis of this variable there is a lot of "unused"
space. Is there a way to reduce this? Is there a way to tell Stata that
this is a categorical variable (factor variables are not allowed...)?
(Of course a recode of the cat var would do the trick but why should
this be the only option?)
My example code with the auto dataset
sysuse auto
recode foreign (0=1) (1=4), gen(for_eu)
replace for_eu = 6 if regexm(make, "Renault")
replace for_eu = 8 if regexm(make, "VW")
replace for_eu = 12 if regexm(make, "Audi")
statsby mean=r(mean) ub=r(ub) lb=r(lb) N=r(N), clear by(for_eu): ci
weight
levelsof for_eu, local(fe)
twoway rcap ub lb for_eu, hori || scatter for_eu mean, ///
legend(off) ytitle("") ylabel(`fe', valuelabel angle(0) nogrid)
Best regards,
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/