From | Roger Newson <[email protected]> |
To | [email protected] |
Subject | Re: st: syntax question - how to put the variable label into a macro |
Date | Wed, 07 Jul 2004 16:03:43 +0100 |
At 15:38 07/07/2004, Ginger Smith wrote:
Hello,To get a variable label into a macro, use the -variable label- extended macro function, as in
I have some data set up in a funny way where the "data" is actually contained in the variable label.
The variables are mt_1_1996 mt_2_1996 mt_3_1996 etc. with an "X" in the column to indicate that the observation goes with the city. The names of the city are in the variable label.
I need to grab the variable label but am having trouble with the syntax.
Here's my code that puts in Akron, OH wherever there is an "X" in any of the variables:
forvalues i = 1(1)89 {;
local tempvar = "Akron, OH" ;
replace mt_`i'_1996= "`tempvar'" if mt_`i'_1996=="X" ;
};
I want to do something like this (the second line is the problem):
forvalues i = 1(1)89 {;
local tempvar = variable label mt_`i'_1996 ;
replace mt_`i'_1996= "`tempvar'" if mt_`i'_1996=="X" ;
};
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |