Statalist


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

st: RE: deleting duplicate observations by date


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: deleting duplicate observations by date
Date   Tue, 13 Jan 2009 14:05:17 +0100

Line for the server...

Maarten`s solution is brilliant! For such probs, let me recommend
http://www.stata.com/support/faqs/data/#dataset
for future reference, although in this particular case, the answer was at
least not obvious...

HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Sharooon
Sent: Tuesday, January 13, 2009 1:29 PM
To: [email protected]
Subject: st: deleting duplicate observations by date

I have a data set with the following format:

id      date     price
1       1         400
2       1         500
2       2         450
2       3         450
3       2         600
3       3          .

Where I have multiple id's observed at different dates, and not necessarily
the same date. What I would like, is to delete all but the most recent date
and fill in the price with the most recent price observed.

For example:

id     date   price
1        1     400
2        3     450
3        3     600

Any clues on how to do this? I've played around with dup and duplicated but
still haven't found anything. 


      
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index