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: Combining graphs addendum


From   Paul <[email protected]>
To   <[email protected]>
Subject   Re: st: Combining graphs addendum
Date   Tue, 11 Feb 2014 16:40:45 +1100

Jorge, thank you for the advice. But still no success with the following
code:

local i=1
foreach v of varlist HIP1824Px HIP1836Px HIP1819Px {
graph bar total_episd_amt if LOS>0 & hospital_group=="" &
separation_fy=="2010/11", over (COMPTOT, relabel(2 "Complication" 1
"NoComplication")) over(`v', relabel(2 "`v'"  1 "Other admissions")) title
("Mean episode amount overnight stays, public hospitals 2010/11") subtitle
("`v' with/without complications") name(panel`i')
local i=`i'+1
}

graph combine panel1 panel2 panel3,cols(1)

The error message: "panel1 is not a memory graph"

I checked the graphs stored in memory using graph describe, and only
panel3 is stored.It is not clear to me why panel1 and panel2 have
disappeared.


Any suggestions?

Paul Gross


On 11/02/14 2:25 PM, "Jorge Eduardo Pérez Pérez" <[email protected]>
wrote:

>You are confusing variables with local macros. Replace the first line
>
>gen i=1
>
>by
>
>local i=1
>
>and the last line in the loop
>
>replace i=i+1
>
>by
>
>local i = `i' +1
>
>
>--------------------------------------------
>Jorge Eduardo Pérez Pérez
>Graduate Student
>Department of Economics
>Brown University
>
>
>On Mon, Feb 10, 2014 at 10:06 PM, Paul <[email protected]> wrote:
>> Sorry, I omitted the graph combine code
>>
>> I have a very large file of 2.3 million hospital admissions, and am
>>using
>> stata v 13.1 on a MacBook Pro
>>
>> I want to create three bar charts of the hospital cost of complications
>>for
>> hip replacement, using three different icd codes for the hip
>>procedures. I
>> want to then  combine the three in one graph.
>>
>> This seemed straightforward with the following loop:
>>
>>
>> gen i=1
>> foreach v of varlist HIP1824Px HIP1836Px HIP1819Px {
>>  graph bar total_episd_amt if LOS>0 & hospital_group=="" &
>> separation_fy=="2010/11", over (COMPTOT, relabel(2 "Complication" 1
>> "NoComplication")) over(`v', relabel(2 "`v'"  1 "  Other admissions"))
>>title
>> ("Mean episode amount overnight stays, public hospitals 2010/11")
>>subtitle
>> ("`v' with/without complications") name(HIP`i')
>>  replace i=i+1
>>  }
>> graph combine HIP1 HIP2 HIP3,cols(1)
>>
>> The error message is : HIP1 is not a memory graph
>>
>> I have tried various combinations of the saving and name conventions,
>> including double quotation marks around the `i' in the name, but none
>>work.
>>
>> Any  ideas, please?
>>
>
>*
>*   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/





*
*   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