Monday, February 27, 2006

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

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 michael.blasnik@verizon.net

----- Original Message ----- From: "Rajesh Tharyan" <R.Tharyan@exeter.ac.uk> To: <statalist@hsphsun2.harvard.edu> 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/


Tag:


Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?