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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Translate Google Trends date system into Stata date system


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Translate Google Trends date system into Stata date system
Date   Tue, 30 Apr 2013 19:37:38 +0100

Yes indeed. You could try -moss- (SSC), but in this case try something like

split awkward, destring parse(-)
gen date1 = mdy(awkward2, awkward3, awkward1)
gen date2 = mdy(awkward5, awkward6, awkward4)
assert date2 == date1 + 6

-split- is a useful command.

Nick
njcoxstata@gmail.com


On 30 April 2013 19:27, Stephen Cranney <scranney@sas.upenn.edu> wrote:
> Hi all,
>
> 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?
>
> Thanks in advance,
>
> Stephen
>
> --
> 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/


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