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

st: AW: converting macros into variables

From   "Martin Weiss" <>
To   <>
Subject   st: AW: converting macros into variables
Date   Fri, 13 Feb 2009 09:32:24 +0100


Interpretation is usually facilitated in these cases with the help of -set
trace on-. Make sure you have - set traceexpand on - so you can see what
Stata makes of your -macro-s. Even with Kieran`s improvement of your code,
you would still end up with an empty dataset unless you -set obs- to
whatever seems appropriate for your particular problem.

BTW, in what kind of a situation would one need such a construct?


-----Ursprüngliche Nachricht-----
[] Im Auftrag von Luhang Wang
Gesendet: Freitag, 13. Februar 2009 05:05
Betreff: 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
How to interprete this?
I guess there is better method to achieve the goal. Any hint will be
*   For searches and help try:

*   For searches and help try:

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