Bob wrote:
I am new to Stata and I want to programmatically generate a list of variable
names in a program which I want to hand over to another program as parameters.
Unfortunately, if I hand the returned macro over as a string, Stata says "
invalid name" and if I don't do that, then the list of variables is converted to
values which is also unwanted.
--------------------------------------------------------------------------------
Try an approach like that illustrated below.
Joseph Coveney
============begin do-file==============
version 11.0
clear *
set more off
program define sender, rclass
version 11.0
syntax
local variable_list
foreach var of varlist _all {
capture confirm numeric variable `var'
if (!_rc) {
local variable_list `variable_list' `var'
}
else {
continue
}
}
return local varlist `variable_list'
end
program define receiver
version 11.0
syntax varlist
summarize `varlist'
display in smcl as text _newline(2) "`varlist'"
end
sysuse auto
sender
receiver `r(varlist)'
exit
============end do-file==============
*
* 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/