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

st: RE: Conserving variables labels while reshaping long a dataset.


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Conserving variables labels while reshaping long a dataset.
Date   Thu, 30 Jan 2003 21:05:59 -0000

[email protected]
> 
> Dear Stata Users,
> 
> How to teel Stata to conserve the labels of variables while 
> reshaping a dataset?
> 

Does -reshape- ever zap variable labels? Evidently. 

Please see 

How can I collapse my dataset and keep the same variable labels?
http://www.stata.com/support/faqs/data/variables.html

I would copy them all before the -reshape- 

foreach v of var * { 
	local l`v' : variable label `v' 
} 

Then after -reshape- check all 
variable labels and replace blanks by 
any saved labels: 

foreach v of var * { 
	local L`v' : variable label `v' 
	if `"`L`v''"' == "" & `"`l`v''"' != "" { 
		label var `v' `"`l`v''"' 
	}
} 
	
Nick 
[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