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]
st: RE: converting string to date
From
Joe Canner <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: RE: converting string to date
Date
Fri, 29 Nov 2013 17:37:05 +0000
Nilay,
You should be able to convert each individual date in the string:
. date1=date(substr(var,1,10),"YMD")
. date2=date(substr(var,14,10),"YMD")
If you want a single date out of this, you could pick one of the dates in the week (date1, date2, or something in between) and use the -week()- function to convert it to a week.
Regards,
Joe Canner
Johns Hopkins University School of Medicine
________________________________________
From: [email protected] [[email protected]] on behalf of Nilay Kumar [[email protected]]
Sent: Friday, November 29, 2013 12:15 PM
To: [email protected]
Subject: st: converting string to date
I have a dataset where weeks are listed as strings ie. 2004-01-04 - 2004-01-10. How can I convert this entire string to dates?
I tried gen date1= date(var, “20YMD”) but that does not seem to work for this
*
* 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/
*
* 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/