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]
Re: st: RE: sorting a bar chart by two variables
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: RE: sorting a bar chart by two variables
Date
Tue, 12 Nov 2013 18:46:16 +0000
You have lost me in detail, but the strategy I pointed to may still be
useful. Whatever you want to order on should be in a variable and
-egen- is a likely way to get that variable.
Nick
[email protected]
On 12 November 2013 18:37, Likosky, Donald <[email protected]> wrote:
> Nick,
>
> Thank you.
>
> It almost gets what I need.
>
> My initial attempt at the egen was to stratify it by "sitelabel".
>
> Each bar represents the percentage of cases within each hospital that had patients at mild hypothermia (lowest3c2) or normothermia (lowest3c3).
>
> What I would like to show is the range of practices across hospitals, with the lowest total percentage on the left, and the highest total percentage on the right. Stated another way, the leftmost center would have a total of say 10% (composed of the total of lowest3c2 and lowest3c3) , and the rightmost bar be a total of 100%.
>
> I don't see that I can use a "by" option with the "egen group" command.
Nick Cox <[email protected]>
> Sounds like
>
> egen group = group(count lowestc2)
>
> ... sort(group)
On 12 November 2013 17:41, Likosky, Donald <[email protected]> wrote:
>> I am trying to create a bar graph and sort it by two variables.
>>
>> I currently am able to sort by the variable "count". I like to sort by a second variable "lowest3c2".
>>
>> Is that possible?
>>
>> Here is my current code:
>>
>> egen count= mean(lowest3c1), by(sitelabel)
>> graph bar lowest3c2 lowest3c3, ylabel(0 "0" .2 "20".4 "40" .6 "60" .8 "80" 1 "100", angle(0)) stack over(sitelabel, label(angle(rvertical)) sort(count) descending) ytitle(Percent) title ("Normothermic or Mildly Hypothermic Cases") legend(rows(1) label(1 "Mild Hypothermia") label(2 "Normothermia") size(*.8)) note("Mild: 32.0-34.9,Normo: 35.0+")
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/