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

st: RE: labels with 'collapse' command


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: labels with 'collapse' command
Date   Fri, 20 Sep 2002 12:34:03 +0100

Iwan Barankay
> 
> I am frequently using the 'collapse' on my datasets and find it 
> frustrating that I lose all my labels as they are replaced by 
> something like
> 
> (mean) oldvar
> 
> is there a way to get around this, i.e. that the odl lables 
> are kept 
> somewhere and then be added to the variables after 'collapse' has 
> been used.
> Any help and suggestions are very appreciated.
> 

Yes. 

1. Before -collapse-, copy the variable labels to local macros: 

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

2. After -collapse-, use the old labels: 

foreach v of var * { 
	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