Statalist The Stata Listserver


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

st: looping through dates and keeping dates which are two years apart


From   "Rajesh Tharyan" <[email protected]>
To   <[email protected]>
Subject   st: looping through dates and keeping dates which are two years apart
Date   Mon, 27 Feb 2006 10:18:58 -0000

Hi,

I have a series of dates as follows

    03nov1989  
    04jan1990  
    15feb1990  
    19feb1990  
    30aug1991  
    03sep1993  
    08aug1995  
    27feb1996  
    06aug1996  
    26feb1997  
    22aug1997  
    30sep1997  
    18feb1998  
    11aug2000  

I want to keep dates if they are two years apart. I tried the command: drop
if date-date[_n-1]<= 730

this gives

03nov1989  
03sep1993  
11aug2000 

This is not the result I want as you will see that the date 27feb1996 is
more than 730 days apart from 03sep1993 but the command actually looks at
03sep1993 and the date previous to that and as the previous date is
27feb1996 (less than 2 years apart) drops it.

The logic of what I want to do is this..but I don't know how to code
it..!!!!

1. Start with the first date.

2. See if the next date is more than 730 days from it. if its less than 73o
days away from the first date drop it.

3. If it is more than 730 days away keep it and 

4. Now this date becomes the reference date and the difference between this
date and the next is calculated and so on





Thanks
Rajesh 




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