Statalist


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

RE: st: RE: AW: creating an ordered month variable over several years


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: AW: creating an ordered month variable over several years
Date   Sun, 29 Nov 2009 23:10:43 +0100

<>

You are allowed to use -graph bar- yourself, of course:


*************
graph hbar (asis) sampled screened noreply, over(m) stack bar(1,
fcolor(green)) bar(2, fcolor(yellow)) bar(3, fcolor(red)) blabel(total)
legend(rows(1))
*************


HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Martin Weiss
Sent: Sonntag, 29. November 2009 22:59
To: [email protected]
Subject: RE: st: RE: AW: creating an ordered month variable over several
years


<>

You are -recast-ing to the -twoway- graph "bar", not the standalone -graph
bar-. If you drilled your way to the very bottom (think
http://www.stata.com/meeting/dcconf09/dc09_radyakin.pdf), you would find
that these two derive from the same substance, but the major demarcation
line for the end user still runs between the -twoway- graphs and the "rest
of world".

Those hyphens in your command need to be stripped off in any event, and the
double comma does have a special meaning which Nick elucidated in a post
some time in the past, but you may want to stick to one per Stata command
:-)


HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Michael McCulloch
Sent: Sonntag, 29. November 2009 21:55
To: [email protected]
Subject: Re: st: RE: AW: creating an ordered month variable over several
years

Martin, that makes sense, and this worked well for the color option,  
but I'm puzzled as to why
	-blabel(total)-
which is a legal option of -graph bar-, produces the error message
	option blabel() not allowed
with the following command:
	*******
	sc sampled screened noreply m,  xla(576/599,angle(90))  name(s,  
replace), fcolor(green yellow red) recast(bar) -blabel(total)-
	*******
Michael

On Nov 28, 2009, at 1:58 PM, Martin Weiss wrote:

>
> <>
>
> The specification of options is to the -recast- graph, not to the  
> original
> one...
>
> *******
> sc sampled screened noreply m, xla(576/599,angle(90))  name(s,  
> replace)
> fcolor(green yellow red) recast(bar)
> *******
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Michael  
> McCulloch
> Sent: Samstag, 28. November 2009 22:47
> To: Statalist Statalist
> Subject: Re: st: RE: AW: creating an ordered month variable over  
> several
> years
>
> Thank you Austin,
> Your suggestion of the -scatter- command with a -recast- option
> provides exactly what I want to display:
> 	sc sampled screened noreply m, recast(bar)
> This command is the last line of the following complete simulation
> example.
>
> However, I have been unable to find how to control color, having
> explored both the option commands for -scatter- and -bar-. Can you
> suggest how to do that? I'm seeking a green/yellow/red color scheme
> for sampled/screened/noreply.
>
>
>
> *** begin example
> clear all
> set seed 1
> set obs 1000
> gen id=_n
> gen month=1 + int(12*uniform())
> gen year=2008 + int(2*uniform())
> gen subject_type=1 + int(3*uniform())
> la def lab_subjects 1 "no reply" 2 "screened" 3 "sampled", modify
> la val subject_type lab_subjects
> g m=(year-1960)*12+month-1
> format m %tmm_CY
> la var m "Calendar month"
> levelsof m, loc(vs)
> foreach v of loc vs {
> la def m `v' "`:di `:format m' `v''", modify
> }
> la val m m
> * insert Nick Cox's cum freq table
> by m, sort: gen freq = _N                  // sort by the variable of
> interest and get the frequencies
> by m: gen cumfreq = _N if _n == 1         // get the cumulative
> frequencies
> replace cumfreq = sum(cumfreq)         // The trick here is to put the
> frequencies once more into a variable, ///
>          but only once within each group. We chose to do this for the
> first observation in each group; that ///
>          is what is meant by _n == 1. In many other problems, we
> could do it also for the last observation ///
>          in each group, but that is not good in this problem. The
> cumulative sum produced by the sum() function ///
>          treats all the missing values produced by the previous
> command as 0, which is precisely what we want. ///
>          That is, the cumulative frequency is, as its definition
> requires, the cumulative sum of just one group ///
>          frequency from each group.
> tabdisp m, cell(freq cumfreq)
>
>
> byhist m, by(subject_type) disc tw(xla(576/599,angle(90) val))
> contract m subject_type, z f(one)
> reshape wide one, j(subject_type) i(m)
> g noreply=max(0,one1)
> g screened=max(0,one1)+max(0,one2)
> g sampled=max(0,one1)+max(0,one2)+max(0,one3)
> sc sampled screened noreply m, recast(bar) xla(576/599,angle(90))
> name(s)
> *** end example
>
>
> Best wishes,
>
> Michael McCulloch
> Pine Street Foundation
> 124 Pine Street
> San Anselmo, CA 94960-2674
> tel:	415-407-1357
> fax: 	206-338-2391
>
> *
> *   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/


Best wishes,

Michael McCulloch
Pine Street Foundation
124 Pine Street
San Anselmo, CA 94960-2674
tel:	415-407-1357
fax: 	206-338-2391

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index