I have code that runs a series of LINREG instructions in a loop, with different dependent variables each time. I want to construct an equation name using those series names (i.e. the labels of the series) and use it with the "define=" option in LINREG. Here is a simple example of what I'm trying to code:
Code: Select all
calendar(q) 1959 1
allocate 50 2015:1
open data nipa.csv
data(format=cdf, org=columns, dateform="m/d/y") 1959:1 2015:1 gdp pce unemp resinv
close data
dofor s = gdp pce resinv
compute eq_name = %l(s) + "_eq"
linreg(print) s /
# unemp{1 to 2} constant
end dofor s
group full_model gdp_eq>>gdp pce_eq>>pce resinv_eq>>resinv
However, this code fails with this error:
Code: Select all
dofor s = gdp pce resinv
(01.0139) compute eq_name = %l(s) + "_eq"
(01.0165) linreg(print, define = eq_name)<<<<
## SX22. Expected Type EQUATION, Got STRING Instead
>>>> s / # unemp{1 to 2} constant
presumably because the eq_name variable contains a string, not an equation name. How can I reference the string contained in eq_name, e.g. "gdp_eq" as an equation name that I can pass into the "define=" option of LINREG (or any other command that optionally takes an equation name)?