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: generate a date (plus 40 days from a start date)


From   "Agnieszka Trzeciakiewicz" <[email protected]>
To   <[email protected]>
Subject   RE: st: generate a date (plus 40 days from a start date)
Date   Tue, 13 Mar 2012 15:58:04 -0000

Thanks. It works perfectly :)
Have a good day.
Agnieszka


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Eric Booth
Sent: 13 March 2012 15:55
To: [email protected]
Subject: Re: st: generate a date (plus 40 days from a start date)


Using the same example as from our other discussion thread, the trick is to
format your dates:

*****************!
clear
**data ex. shortened a bit:===>
inp str15 fulldate	firm_id	director_id	mark
"22/10/2002"	1	7	0
"07/04/2003"	1	7	0
"11/04/2003"	1	7	0
"01/10/2003"	1	7	0
"01/10/2003"	1	7	0
"20/10/2003"	1	7	0
"07/04/2004"	1	7	0
"08/04/2004"	1	7	0
"16/04/2004"	1	7	0
"25/10/2004"	1	7	1
"12/11/2004"	1	7	0
"07/04/2005"	1	7	1
"27/04/2005"	1	7	1
"25/08/2005"	1	7	0
"05/09/2005"	1	7	0
"12/09/2005"	1	7	0
"25/10/2005"	1	7	1
"25/04/2006"	1	7	1
"25/04/2006"	1	7	1
"05/09/2006"	1	7	0
"05/09/2006"	1	7	0
"28/09/2006"	1	7	0
"28/09/2006"	1	7	0
"28/09/2006"	1	7	0
"28/09/2006"	1	7	0
"28/09/2006"	1	7	0
"25/10/2006"	1	7	1
"27/04/2007"	1	7	1
"27/04/2007"	1	7	1
"06/09/2007"	1	7	1
"06/09/2007"	1	7	1
"06/09/2007"	1	7	1
"06/09/2007"	1	7	1
end
drop mark

**format dates
*see -help dates-
g date = date(fulldate, "DMY")
format date %td


g enddate = date +40
format enddate %td

*****************!

- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754











On Mar 13, 2012, at 9:40 AM, Agnieszka Trzeciakiewicz wrote:

> 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?search
> *   http://www.stata.com/support/statalist/faq
> *   http://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/

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index