Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: keeping variable labels after -collapse-


From   Christopher Baum <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: keeping variable labels after -collapse-
Date   Sun, 6 Jan 2013 16:10:42 +0000

<>
On Jan 6, 2013, at 2:33 AM, annoporci wrote:

> I found it tedious to copy the pieces of code everytime I needed to
> - -collapse- so I implemented Nick's algorithm by saving the pieces of code
> in separate files and -include- ing them into the master code.
> 
> In practice, you only need to remember to "squeeze" -collapse between
> "include copylabels" and "include attachlabels".
> 
> My contribution is modest, but I send it to Statalist for the record.
> 
> All credit goes to Nick Cox. Thanks.
> 
> Like so:
> 
>      sysuse sp500,clear
> 
>      sort date
>      tsset date
>      gen qdate = qofd(date)
>      format qdate %tq
>      local variables open close
> 
>      cd "C:\stata\labels\"
> 
>      include copylabels
>      collapse (mean) `variables', by(qdate)
>      include attachlabels
> 

Ingenious, but somewhat unncessary, as Stata will do this for you:

label save using whatever.do
replace...
do whatever.do

will restore the labels.

Kit

Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
                             An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
  An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index