On Apr 30, 2013, at 1:27 PM, Stephen Cranney wrote:
> I'm trying to get long series of dates I downloaded from Google Trends to function in Stata. Unfortunately, Google Trends's way of doing dates makes this difficult. An example value from a single observation:
>
> 2004-01-04 - 2004-01-10
>
> This represents the week of January 04, 2004 to January 10, 2010. However, Stata is (understandably) reading this as a string variable. Is there a way to take variables like this and break them into a beginning date and ending date or something similar?
Several ways, e.g.,
if regexm("2004-01-04 - 2004-01-10","^([0-9\-]+) - ([0-9\-]+)$") ///
di %td date(regexs(1),"YMD"), %td date(regexs(2),"YMD")
-- Phil
*
* 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/