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" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
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 
n.j.cox@durham.ac.uk 
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index