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   Chamara Anuranga <[email protected]>
To   [email protected]
Subject   Re: st: keeping variable labels after -collapse-
Date   Tue, 8 Jan 2013 09:26:00 +0530

Dear All,

Why we can't use original data file and keep 1st record and append
with collapsed data? Then we can drop first observation from the
dataset. I came across this method somewhere on the web and it works
for me most of the time.

Example

sysuse auto,clear
collapse price mpg headroom trunk weight length turn displacement
gear_ratio,by(rep78 foreign)
save "temp.dta",replace

sysuse auto,clear
keep in 1
append using temp.dta
drop in 1
keep price mpg headroom trunk weight length turn displacement
gear_ratio rep78 foreign



Thanks,
Chamara



On Tue, Jan 8, 2013 at 1:27 AM, Roger B. Newson <[email protected]> wrote:
> Yes, -descsave- can do this (with a -do()- option), if the output variable
> has the same name as the input variable. In the examples quoted, however,
> there are prefixes and suffixes, so we have to do some additional looping.
>
> I hope this helps.
>
> Best wishes
>
> Roger
>
> Roger B Newson BSc MSc DPhil
> Lecturer in Medical Statistics
> Respiratory Epidemiology and Public Health Group
> National Heart and Lung Institute
> Imperial College London
> Royal Brompton Campus
> Room 33, Emmanuel Kaye Building
> 1B Manresa Road
> London SW3 6LR
> UNITED KINGDOM
> Tel: +44 (0)20 7352 8121 ext 3381
> Fax: +44 (0)20 7351 8322
> Email: [email protected]
> Web page: http://www.imperial.ac.uk/nhli/r.newson/
> Departmental Web page:
> http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/
>
> Opinions expressed are those of the author, not of the institution.
>
>
> On 07/01/2013 17:49, David Radwin wrote:
>>
>> Can't this be done with Roger Newson's -descsave- (SSC)?
>>
>> http://ideas.repec.org/c/boc/bocode/s418101.html
>>
>> David
>> --
>> David Radwin
>> Senior Research Associate
>> MPR Associates, Inc.
>> 2150 Shattuck Ave., Suite 800
>> Berkeley, CA 94704
>> Phone: 510-849-4942
>> Fax: 510-849-0794
>>
>> www.mprinc.com
>>
>>> -----Original Message-----
>>> From: [email protected] [mailto:owner-
>>> [email protected]] On Behalf Of daniel klein
>>> Sent: Sunday, January 06, 2013 9:34 AM
>>> To: [email protected]
>>> Subject: Re: st: keeping variable labels after -collapse-
>>>
>>> I did indeed overlook something, as -uselabel- will not help here,
>>> either. Seems there is no canned way to save variable labels.
>>>
>>> Best
>>> Daniel
>>>
>>> --
>>> I might be overlooking something here, but the question is/was about
>>> _variable_ labels, not _value_ labels. As far as I see, -label save-
>>> just saves and "restores" the latter. -uselabel- may be used, but it
>>> seems more burdensome than the few lines of code Nick suggested.
>>>
>>> Best
>>> Daniel
>>
>>
>> *
>> *   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/
*
*   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