| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: looping through dates and keeping dates which are two years apart
From |
"Michael Blasnik" <[email protected]> |
To |
<[email protected]> |
Subject |
st: Re: looping through dates and keeping dates which are two years apart |
Date |
Mon, 27 Feb 2006 08:22:32 -0500 |
I think this should do what you want.
sort date
gen days=date-date[_n-1]
qui count if days<730
while r(N)>0 {
drop if days<730
replace days=date-date[_n-1]
qui count if days<730
}
Michael Blasnik
[email protected]
----- Original Message -----
From: "Rajesh Tharyan" <[email protected]>
To: <[email protected]>
Sent: Monday, February 27, 2006 5:18 AM
Subject: st: looping through dates and keeping dates which are two years
apart
<snip>
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
*
* 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/