Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: STATA date question


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: STATA date question
Date   Wed, 29 Jan 2014 19:23:57 +0000

One approximation is that 18 months on is 366 + 183 = 549 days away.

gen newdate = date + 549

Then to get Thursdays we need -dow(newdate)- to be 4. Thus we could
say that if -dow(newdate)- is 5 or 6, we subtract 1 or 2; if 0,1,2, or
3 we add 4,3,2, or 1.

That boils down to

replace newdate = cond(dow(newdate) <= 4, newdate + 4 - dow(newdate),
newdate - 4 + dow(newdate))

For "STATA" read "Stata" throughout.

Nick
[email protected]


On 29 January 2014 14:13, Ed Levitas <[email protected]> wrote:

> I'm trying to output dates  that occur on the Thursday after 18 months have passed since a beginning date. For example, assume my beginning date is January 1, 2014.  The Thursday after 18 months have passed from this date is July 2, 2015.  In this case, I am not concerned with how many days are in each month (e.g., I don't care that January 2014 has 31 days and February 2014 has only 28).  I treat month duration as equivalent regardless of days within each month.    I have examined datetime  but am still unsure as to how to accomplish this in STATA.  Can you please suggest a way in STATA to produce this output?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index