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   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: keeping variable labels after -collapse-
Date   Sun, 6 Jan 2013 16:20:49 +0000

The FAQ concerned dates to 2002 (revised 2003): there's a simple
question whether -label save- existed then. (I am away from my old
manuals.)

That said, the macro-based method has some uses. Kit's technique
presupposes that the variables have the same names before and after
-collapse-, and if that's so it solves the problem completely. But
once you start -collapse-ing to new variable names, you will need
something where you have more control.

Nick

On Sun, Jan 6, 2013 at 4:10 PM, Christopher Baum <[email protected]> wrote:
> <>
> 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/
*
*   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