Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: about stacked mean bar chart

From   Roger Harbord <>
To, Nick Cox <>
Subject   Re: st: RE: about stacked mean bar chart
Date   Fri, 01 Nov 2002 15:16:14 -0000

--On 01 November 2002 09:52 +0000 Nick Cox <> wrote:

Xiaoqu Luo

I want to creat stacked bar chart where each bar stands for
the mean of a variable. I tried using "graph v1 v2 v3, bar
means by (v4) stack" to produce this but STATA said that it
was invalid. It looks like "stack" cannot be used with
means (i.e. "stack" option can only have the bar to
represent counts). Do you have any idea to do  stacked bar
chart on mean?
I guess that -graph, bar- was written with
the notion that people might want to stack
totals, but not means.

One work-around would be as follows:

1. Create variables which are means
and give them the same variable labels as
the originals:

foreach v of var v1 v2 v3 {
	bysort v4 : egen mean`v' = mean(`v')
	_crcslbl mean`v' `v'

Okay Nick, I have to ask - how did you know that _crcslbl existed and what it did? There are no help files for the _ commands. Only a couple (literally) are documented in [P]. I've gathered that programs beginning with _g are -egen- functions. What are all the programs beginning with _crc?

On a (possibly) related point:

Does anyone know how to make a copy of a value label, so that I can then modify one or more of the # to label correspondences ?
Say I decide to combine the upper groups of a grouped income variable (because I'm analysing a subpopulation with few rich people, say):

. gen income5=income10
. recode income5 5/max=5

Now I need to copy make a copy of the value label associated with income10 and modify the label corresponding to 5. (I don't want to modify the original label as I still want to keep income10 in the dataset too). Surely there should be a way of doing this without writing a loop starting
-forvalues i=1/4- ? None of the -label- commands will do this, and Nick Cox's -labcopy- on SSC is designed to do something slightly different. Might there be an _ command to do this too? How would I find out? I had a quick look in C:\Program Files\StataSE\ado\base\_ and discovered there are a lot of .ado files but no .hlp files!

Roger Harbord
Department of Social Medicine, University of Bristol

* For searches and help try:

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