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

st: syntax question - how to put the variable label into a macro


From   Ginger A Smith <[email protected]>
To   [email protected]
Subject   st: syntax question - how to put the variable label into a macro
Date   Wed, 07 Jul 2004 10:38:47 -0400

Hello,

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" ;
};

Thank you very much for your help,
Ginger Smith

************************
University of Michigan
Departments of Economics
and Health Management and Policy

Room M3041, SPH II
109 S. Observatory St.
Ann Arbor, MI 48108-2029

[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