Hello,
I have to draw I have to draw a variety of similar graphs and decided to use macros at first time. I'm working at Stata 13
Without macros it looks like
graph twoway (lpoly Factor1 Year if (Status == 1)&(Group == 1), degree(4))(lpoly Factor1 Year if (Status == 0)&(Group == 1), degree(4))
graph export F1_Factor1.png
graph twoway (lpoly Factor2 Year if (Status == 1)&(Group == 1), degree(4))(lpoly Factor2Year if (Status == 0)&(Group == 1), degree(4))
graph export F1_Factor2.png
...
and so on (it works properly)
However, when I type
foreach var of varlist Factor1 Factor2 {
graph twoway (lpoly 'var' Year if (Status == 1)&(Group == 1), degree(4))(lpoly 'var' Year if (Status == 0)&(Group == 1), degree(4)), name(`var', replace)
}
I get an error that
‘var’ invalid name
Moreover, If I type just
foreach var of varlist Factor1 Factor2 {
twoway scatter `var' YEAR || lfit `var' YEAR, name(gr`var', replace)
}
It works well, but with this syntax I can' add degree(4), which is crucial.
Could anybody please help?
Related Posts with Macros for 2 graphs. Invalid name error
Xtabond2 lagged endogenous variableHi there, I am estimating the relationship between growth and inequality using dynamic panel data. …
Poisson with Robust SE showing totally different results from Log-OLS and NBHi, This is the first time I post question here. I've read pretty much all the posts on Poisson reg…
reghdfe dkraayI am having trouble with the syntax for reghdfe. I would like to run a regression using reghdfe that…
_all: in mixed models: What if it is followed by a continuous variable without the "R." part?Dear Statalist, I am trying to better understand how Stata deals with the _all: option in mixed/xtm…
Ranking/categorizing firms based on the value of a variable in a specific yearHi I am working with a panel data set with c300 firms from years 2008 to 2014, with several firm-le…
Subscribe to:
Post Comments (Atom)
0 Response to Macros for 2 graphs. Invalid name error
Post a Comment