foreach v of local varlist {
local list `" `list' "`v'", "'
}
adds a comma too many, so I guess
you need something like this
tokenize "`varlist'"
local nv : word count `varlist'
forval i = 1/`=`nv' - 1' {
local list `" `list' "``i''", "'
}
local list `" `list' "``nv''" "'
Nick
[email protected]
Fred Wolfe
> Can anyone help with this macro question:
>
> In a program syntax statement
>
> syntax, vlist(varlist)
>
> I create a local macro vlist which end up containg:
>
> di"`vlist'"
>
> plaghaq_disability plaghaq2 plagpas
>
> I want to use the contents of that macro in an inlist()
> function like this:
>
> if inlist(parm,"plaghaq_disability", "plaghaq2", "plagpas")
>
> So I need to transform
>
> this list:
> plaghaq_disability plaghaq2 plagpas
>
> into this list:
>
> "plaghaq_disability", "plaghaq2", "plagpas" in a macro. I am having
> problems adding the quotation marks.
>
> Can anyone tell me how to do this?
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/