Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Macro question


From   Fred Wolfe <[email protected]>
To   [email protected]
Subject   Re: st: RE: Macro question
Date   Tue, 15 Mar 2005 10:06:49 -0600

Thanks Nick and Nick.

I modified the code slightly for my application, and I get the same error with the two suggested methods. Suggestion?

local vlist: list clean vlist
local olist : subinstr local vlist `" "' `"", ""' , all
local olist `""`olist'""'
di "`olist'"


callparmby "reg totcost03 age sex `var'",fwrelabel pformat(%9.3f) eformat(%9.1f) vlist(plaghaq_ plaghaq2 plagpas)
plaghaq_disability", "plaghaq2", "plagpas"" invalid name
r(198);


Fred


At 09:47 AM 3/15/2005, you wrote:

Assuming you can be sure that the varlist is tokenized with single spaces, with no leading or trailing spaces (which should be true if it comes through -syntax-, how about:

. local varlist : subinstr local varlist `" "' `"", ""' , all
. local varlist `""`varlist'""'

The first step changes each space into ", "
the second step adds the leading and trailing quotation marks.

--Nick WInter


At 03:39 PM 3/15/2005 +0000, you wrote:

> 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
--------------------------------------------------------
Nicholas Winter                           607.255.8819 t
Assistant Professor                       607.255.4530 f
Department of Government              [email protected] e
308 White Hall            falcon.arts.cornell.edu/nw53 w
Cornell University
Ithaca, NY 14853-4601

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

Fred Wolfe
National Data Bank for Rheumatic Diseases
Wichita, Kansas
Tel (316) 263-2125     Fax (316) 263-0761
[email protected]


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



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