Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Winter <njgwinter@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Translate Google Trends date system into Stata date system |
Date | Wed, 01 May 2013 12:41:12 -0400 |
Or, for maximum concision (and obfuscation): forval i=1/2 { generate date`i' = date(substr(googledate, 12-11*`i' ,10),"YMD") format date`i' %td } On 5/1/2013 12:21 PM, Sergiy Radyakin wrote:
tempvar d1 d2 generate `d1'=substr(googledate,1,10) generate `d2'=substr(googledate,-10,.) generate date1=date(`d1',"YMD") generate date2=date(`d2',"YMD") format date1 %td format date2 %td list On Tue, Apr 30, 2013 at 3:13 PM, Nick Cox <njcoxstata@gmail.com> wrote:That's fine. But in order that no-one gets confused: 1. -parse()- here is the name of an option. 2. -parse- is a quite distinct and out-of-date command. The connection is only that I had parsing in mind when I wrote the original version of -split-, itself a rewrite of -strparse- by Michael Blasnik and myself, still visible on SSC. Nick njcoxstata@gmail.com On 30 April 2013 20:05, Stephen Cranney <scranney@sas.upenn.edu> wrote:The split and -parse- commands worked perfectly for my purposes. Thank you. On Tue, Apr 30, 2013 at 2:38 PM, Phil Schumm <pschumm@uchicago.edu> wrote: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/-- Stephen Cranney PhD Student Graduate Group in Demography University of Pennsylvania * * 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/* * 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/