Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: graph bar, x-axis and dates


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: graph bar, x-axis and dates
Date   Thu, 21 Apr 2011 18:04:57 +0100

My script does not explain how to calculate percents. WIth -twoway
bar- or -twoway rbar- you do need to do that yourself.

gen pcspecial = 100 * nspecial / ntotal
gen pctotal = 100

On Thu, Apr 21, 2011 at 5:24 PM, Nick Cox <njcoxstata@gmail.com> wrote:
> This is just a standard example or -twoway bar- and/or -rbar-.
>
> clear
> set obs 360
> gen date = 144 + _n
> format date %tm_M_CY
> gen nspecial = floor(1000 * runiform())
> gen ngeneral = floor(1000 * runiform())
> gen ntotal = nspecial + ngeneral
> twoway bar nspecial date || rbar nspecial ntotal date, legend(order(1
> "special" 2 "general")) xla(180(60)460, format(%tm_CY))
>
> Special points:
>
> The height of the highest bar will be the sum of the heights of the
> bars it contains. You need to calculate that for yourself.
>
> In your case, your counts need to be constructed as
>
> egen nspecial = count(special), by(date)
> egen ngeneral = count(general), by(date)
>
> On Thu, Apr 21, 2011 at 4:57 PM, Ben Ammar <Ben-Ammar@gmx.de> wrote:
>> Hi everyone,
>>
>> I've got a panel dataset, where I want show the developement of two different groups in the course of time which worked fine by the following command:
>>
>> graph bar (count) special general, over (date) stack percentage
>>
>> Unfortunately, since there are more than 30 years of monthly data, the x-axis is filled with dates that it can't be read anymore. Is there a way that the graph shows only years, preferably in 5 year steps?
>> I know that this is a time series graph so there should be in fact also a command like tsrline to avoid my problem. However I couldn't find anything that creates a graph like the above mentioned (stacked percentage of both groups in each month). I also checked "A visual guide to stata graphics" by Michael Mitchell but I couldn't find anything about a similar graph.
>

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