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

st: RE: AW: RE: display all categories on pie chart for categorical variables (with some zero values)

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: AW: RE: display all categories on pie chart for categorical variables (with some zero values)
Date   Thu, 26 Nov 2009 13:05:43 -0000

-fulltab- could be fixed, but as it's broken, you should consider other

I'd look into a -reshape-, so that your variables become subsets. 

With data like this, not every category is represented. 

set obs 20
set seed 2803
forval j = 1/5 {
	gen y`j' = ceil(10 * runiform())

So, we -reshape-. 

gen id = _n
reshape long y, i(id)
graph pie , over(y)  by(_j)

I'd also not use pie charts! 

[email protected] 

Martin Weiss

-ssc d fulltab- is quite old (1998), so to get it to work, you have to
specify an appropriate -version-:


input a b c
2 3 1 
4 5 1
1 2 1
3 6 0

list, noo

version 7: fulltab a b if c==1, vals(1 2 3 4 5 6) m(mymat)

Weirdly enough, -fulltab- does not include a -version- statement in its

Adam Collins

I expect there is something really simple that I am missing here... but
I am
new to Stata and it is doing my head in that I can't display all
of a categorical variable on a pie chart...  I am really getting no
with this problem.  I would really appreciate some help.

I tried exploring ways of storing the "counts" from my categorical
values in another variable, such as a matrix which would allow me to
store a
"zero count" as a "0" value.  In searching for a solution, I came
-fulltab- (from SSC), however it doesn't seem to work (it just displays
following "program error:  code follows on the same line as open

Anyway, I am not even sure this is the best approach.  Surely there is
something more straight forward?

Adam Collins

I have several categorical variables that each possess the same list of
categories (value labels).  

To enable easy comparison of the pie charts, I would like every category
exist on every chart (so that each category retains the same
colour/settings/legend position etc on each chart).

The problem is that some of the variables contain zero occurrences of
certain values (categories) and the standard 'over(varname)' option with
-graph pie- excludes categories with no occurrences.  I have tried the
'allcategories' option, but since it applies to the 'over()' variable,
does not help.

Does anyone have any ideas?  (by the way, since this is for a specific
of categorical variables, it is fine if the categories are 'hard coded',
then applied to each variable)

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index