Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: RE: combining data on same case from different lines


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: combining data on same case from different lines
Date   Fri, 25 Jun 2010 14:41:00 +0100

I don't understand the difference. But this FAQ may be useful: 

How can I replace missing values with previous or following nonmissing values or within sequences?

http://www.stata.com/support/faqs/data/missing.html

And -- here explicitly checking that observations occur in pairs -- 

bysort id : replace myvar = myvar[3-_n] if missing(myvar) & _N == 2 

will replace a missing value of -myvar- with its pair within blocks of -id-. 

Nick 
n.j.cox@durham.ac.uk 


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Marcelo Jenny
Sent: 25 June 2010 14:25
To: statalist@hsphsun2.harvard.edu
Subject: st: combining data on same case from different lines

Hello Nick,

thanks for the reply. It's not that easy :)

The table got bungled in the last email:
id date      stage      publication
1  01oct1990 indictment
1            indictment journal 3
2  10may1995 indictment
2            indictment journal 5

I want to arrive at a table with complete data on all variables for all
cases. This means either the data in the variable 'publication' in the 
second
line of case 1 needs to be copied into the first line or the data in the
variable 'date' needs to be copied into the second line.

Afterwards I can drop the now unnessary second line for each case in
the way you suggested.

Marcelo

-- 
Dr. Marcelo Jenny
Universität Wien
Institut für Staatswissenschaft/AUTNES
Hohenstaufengasse 9/7/4. Stock
A-1010 Wien
Tel.:++43-1-4277-49706
E-Mail: marcelo.jenny@univie.ac.at
http://staatswissenschaft.univie.ac.at/

*
*   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   |   Site index