Statalist


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

st: AW: Merging observations


From   Jochen Späth <jochen.spaeth@iaw.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: Merging observations
Date   Thu, 11 Dec 2008 09:34:09 +0100

Hi Jim,

I am wondering if case and person are actually the only identifiers in your data set because they do not uniquely identify your observations, maybe you should check this with the -unique- command first (if not installed type 
-ssc install unique-). Anyway, if they are the only identifiers as you stated in your question, you could try -collape var1 var2 var3, by(case person)-. This, however, will only help if per case and person you have really only one non-missing observation in each variable to be collapsed, as showed in your example. Otherwise, the collapsed mean would be false.

HTH,
Jochen
-------------------------------------------------------------------------------------------
Jochen Späth
Dipl.-Volkswirt
Institut für Angewandte Wirtschaftsforschung (IAW) Tübingen
Ob dem Himmelreich 1
72074 Tübingen
Tel.: +49-(0)7071-9896-14
Fax: +49-(0)7071-9896-99
EMail: jochen.spaeth@iaw.edu
IAW-Homepage: www.iaw.edu
------------------------------------------------------------------------------------------- 
-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Jim O'Grady
Gesendet: Donnerstag, 11. Dezember 2008 08:57
An: statalist@hsphsun2.harvard.edu
Betreff: st: Merging observations

Hi Folks,

I'm hoping this is a simple question :)

I have a dataset like this:

Case Person var1 var2 var3
345   01         1     .      .
345   01         .      1     .
345   02         .      1     .
345   02         .      .      1

I want to merge the observations which have the same identifiers (case
and person) to get

Case Person var1 var2 var3
345   01         1     1      .
345   02         .      1     1

All help appreciated,

Thanks,

Jim
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/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/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