Bookmark and Share

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: Request help regarding bar graph


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Request help regarding bar graph
Date   Sat, 22 Jun 2013 09:34:16 +0100

I think you need a reduced dataset in which this becomes trivial.

This is not literal code for your situation, more a sketch. What you
want plotted is not totally clear to me, so these are just hints.

preserve
keep if admission_reason == "surgical"
separate cost, by(readmission)
collapse (sum) cost?, by(something)
gen totalcost = <sum of cost variables>

and then the graph should be easier.

Nick
[email protected]


On 22 June 2013 03:37, Michael Stewart <[email protected]> wrote:

> I am posting to get help regarding graph bar ,
>
> I am using Stata 12.1 .
>
> My goal is to display my data as a bar graph with three  bars
>
> 1)BAR-1: Total Cost of care for patients(admitted once)  when
> ADMISSION_REASON=="SURGICAL"
> 2)BAR-2: Total Cost of care for patients readmitted(admitted more than
> once)) when ADMISSION_REASON=="SURGICAL"
> 2)BAR-3: Total cost if ADMISSION_REASON=="SURGICAL"
>
> My dataset (with details regarding cost and resource utilization for
> thousands of patients) is as follows( in simplified format) .
>
> *************Dataset
> Begin********************************************************
> ID  HOSPITAL_NAME    ADMISSION_SEQUENCE    ADMISSION_REASON    COST
> 1    AA                                    1
>              MEDICAL            $$
> 1    AA                                    2
>             MEDICAL            $
> 1    SS                                    3
>            SURGICAL        $$$
> 1    BB                                    4
>            MEDICAL            $$
> 2    AA                                    1
>            MEDICAL            $
> 2    DD                                    2
>            SURGICAL        $$$
> 2    EE                                    3
>           MEDICAL            $
> 2    RR                                    4
>            MEDICAL            $$$
> 2    TT                                     5
>             SURGICAL        $$$
> 3    xx                                     1
>             SURGICAL        $$$$
> 4    RR                                    1
>            SURGICAL        $$$$$
> *************Dataset End********************************************************
>
> I was able to draw a Bar-1 and Bar-2 graphically display the cost
> among patients from two groups without a problem. However adding a
> third bar(height is equal to sum of the cost of all surgical
> admissions) is proving to be rather difficult.
>
> My code(so far) is as follows :
>
> Step-1: gen readmission variables as follows
> bysort ID : gen n=_N
> gen readmission=n==1
>
> Step-2: graph bar (sum) COST if
> ADMISSION_REASON=="SURGICAL",over(readmission)  blabel(bar)
>
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index