Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: generate a date (plus 40 days from a start date)


From   Ras Dondo <ras.dondo@yahoo.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: generate a date (plus 40 days from a start date)
Date   Thu, 15 Mar 2012 16:10:30 -0700 (PDT)

Hi Agnieszka,

You should have stated the version of Stata you are using as this guides whoever is responding to your question.

Anyway, back to your question

1. Make sure you have your date formatted as Stata date if it is not already done. For Stata 9 you can use this command - format date %d - 

2. Now use this command to get what you want - generate newdate=date+40 - .This will generate the new date but if you list you will only see numbers and not dates. To get the results in date format use this command - format date %d - 


All the command are combined for you below:
format date %d 
generate newdate=date+40 

format newdate %d  


All the best

Ras



----- Original Message -----
From: Agnieszka Trzeciakiewicz <agazto@gmail.com>
To: statalist@hsphsun2.harvard.edu
Cc: 
Sent: Tuesday, March 13, 2012 3:40 PM
Subject: st: generate a date (plus 40 days from a start date) 

Hi,
I am trying to write a formula, that will generate an end date variable
which will be distance from a start date for 40 days.
For instance start date is 1/09/2000 end date should be 10/10/2000
(1/09/2000+40 days)
Thanks,
Agnieszka

*
*   For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/statalist/faqhttp://www.ats.ucla.edu/stat/stata/


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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index