Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: program to generate variable list as input for other program


From   Bob <[email protected]>
To   [email protected]
Subject   st: program to generate variable list as input for other program
Date   Sat, 9 Jan 2010 19:06:02 -0800 (PST)

Hi,

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.

Here is some example code:

gen a1=0
gen a2=1
program define test, rclass
	local s "a1 a2"
	return local mvl "`s'"
end

program define test2
	syntax varlist(min=0 max=100)
	di `0' `1'
end

test
test2 r(mvl)
test2 `r(mvl)'
test2 "`r(mvl)'"

Thanks a lot for your help!

Bob


      
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index