Statalist


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

st: RE: converting macros into variables


From   "Kieran McCaul" <[email protected]>
To   <[email protected]>
Subject   st: RE: converting macros into variables
Date   Fri, 13 Feb 2009 14:38:14 +0900

gen `v' = ``v''


______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2140
Fax: (08) 9224 8009
email: [email protected]
http://myprofile.cos.com/mccaul 
http://www.researcherid.com/rid/B-8751-2008
______________________________________________
The fact that no one understands you doesn't make you an artist.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Luhang Wang
Sent: Friday, 13 February 2009 1:05 PM
To: [email protected]
Subject: st: converting macros into variables

Hi All,
Does anyone know an easy way of converting macros into variables?
I'm trying something like the following.
local x1=1
local x2=2
local vl "x1 x2"
foreach v of loc vl {
        gen "`v'"=`"`v'"'
}
I end up with error message
"x1 invalid name
r(198);
How to interprete this?
I guess there is better method to achieve the goal. Any hint will be
appreciated.
Thanks.
Luhang
*
*   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/



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