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: Graph editor: Change order of subgraphs in bygraph ?
From
Scott Merryman <[email protected]>
To
[email protected]
Subject
Re: st: Graph editor: Change order of subgraphs in bygraph ?
Date
Thu, 18 Aug 2011 09:58:01 -0500
I remember reading in Kit Baum's "An Introduction to Stata
Programming" that *.gph files were actually programs to reproduce the
graph.
Looking back at section "10.5 Extracting data from graph files'
sersets" shows that there is an easier way:
//create original graph
sysuse sp500,clear
xtile g= date, n(4)
twoway bar change date , by(g, rescale ) xlabel(, labsize(*.7))
graph save Graph "C:\Documents and
Settings\scott.merryman\Desktop\Graph.gph",replace
//extract data from graph
cd "C:\Documents and Settings\scott.merryman\Desktop\"
clear*
serset clear
graph use "Graph.gph"
serset dir
serset
forv i = 0/`=r(id)' {
serset set `i'
serset use
gen group = `=`i'+1'
save temp`i'.dta,replace
local files "`files' temp`i'.dta "
}
clear
append using `files'
clonevar gr2 = group
replace gr2 = 4 if group == 1
replace gr2 = 1 if group==4
label define group 1 "4" 2 "2" 3 "3" 4 "1"
label value gr2 group
twoway bar change date , by(gr2, rescale ) ///
xlabel(, labsize(*.7)) name(graph_new,replace)
Hope this helps,
Scott
On Thu, Aug 18, 2011 at 1:52 AM, Jesper Lindhardsen
<[email protected]> wrote:
> Scott, You are a lifesaver. This works perfectly. I must confess I am
> intrigued as to how you came up with this solution?
> On a personal note, I do think one should have this possibility
> available from inside the editor, rather than hacking stata graph
> files!!!!!
>
> Thanks,
>
> Jesper
>
*
* 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/