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

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


From   "Neil Shephard" <[email protected]>
To   [email protected]
Subject   Re: st: syntax question - how to put the variable label into a macro
Date   Wed, 07 Jul 2004 15:54:33 +0100

> 
> 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" ;
> };
> 
I'm not sure if the answer you need is in there but a similar question was posted by 
Maoyong Fan on Friday Jun 18th and answers were proffered by Renzo Comolli, Lee 
Chuntao and Nick Cox.

Links to the Stata list archives are at the top of http://stata.com/support/statalist/ (there 
are three mirrors of the archives).

HTH's

Neil

Neil Shephard
Genetics Statistician
ARC Epidemiology Unit, University of Manchester
[email protected]
[email protected]

"Contrariwise, if it was so, it might be; and if it
were so it would be; but as it isn't, it ain't. That's
logic" - Tweedledee (Alice Through the Looking Glass)

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