Good morning everyone,
I have an issue concerning a program which goal is to run an OLS. I name that program "OLS". I have several arguments in that program, including one name "covariates". When calling program "OLS", I would like to give as "covariates", a local macro called X, containing a list of variables. It does not work. Only the first covariate of the list in the macro is used. And it is clearly the problem: once I change "covariates" in the call by "var1 var2 etc...", i.e without using the local macro X, it works (everything is used). Someone could help me ? I doubt that it is impossible to do such a thing. Thank you in advance. Code below.
###
capture program drop OLS
program OLS
args model_name sample treatment group outcome covariates reweight
eststo `model_name': quietly regress `outcome' `treatment' `covariates' if (`sample'==1 & `group'==1) [aw=weight*`reweight'], vce(robust)
end
###
###Call1###
local X "var1 var2 var3"
OLS model_name sample treatment group outcome `X' reweight
###
--> Only takes var1 in X
But here :
###Call1###
OLS model_name sample treatment group outcome "var1 var2 var3" reweight
###
It takes everything of course.
Related Posts with macro as program argument
question about didregressDear all, When I run the example code of didregress,I get very different result from Stata.com Diff…
Constructing dummy for treated firms in a diff in diff Hi everyone, I am asking your help in order to build a dummy variable for treated companies, useful…
Please help meHello everyone. I'm new in STATA and I need help for this problem. I have a Variable (Var1) which ha…
xtlogit: hybrid model by hand. How to obtain average marginal effects using mimrgnsHello everyone, for my current research, I employ a hybrid logit model for a binary outcome variabl…
Stata 17 table helpHi, all. I am working with the updated -table- command in Stata 17, and am looking to produce a fair…
Subscribe to:
Post Comments (Atom)
0 Response to macro as program argument
Post a Comment