Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: dates question


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: dates question
Date   Tue, 28 Aug 2007 20:40:35 +0100

This arrived truncated. However, there is an FAQ 

FAQ     . . . . . . . . . . . . . . . . . . . . . . . Generating the last date
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        4/05    How can I generate a variable containing the last of
                several dates?
                http://www.stata.com/support/faqs/data/lastdate.html

which despite its title is of some relevance. 

The earliest date is just the minimum. None of the complications
that surround dates affect this point, so long as your dates 
are in numeric form. Hence, if your structure is 

id date_1 date_2 date_3

then the earliest date is 

gen earliest = min(date1, date2, date3) 

and if your structure is of 

id   date
---------- 
id_1 date_1 
id_1 date_2 
id_1 date_3 
id_2 date_1 
... 

then the earliest date is 

bysort id (date) : gen earliest = date[1] 

Nick 
[email protected] 

Grosso Anthony
 
> with 3 columns (variables) of different dates. How can Stata 
> identify/keep the earliest date for each observation?

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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