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: Fwd: Converting weekly data of form yyyyww
From
Ruth Gilgenbach <[email protected]>
To
[email protected]
Subject
st: Fwd: Converting weekly data of form yyyyww
Date
Wed, 25 Jul 2012 07:55:13 -0500
I have a data set with variable "dates" which are of the form yyyyww,
and I am trying to convert them to a useable format, and am having no
luck. I am running Stata 12.
For example, if I use the following
************************
inp str06 dates
201002
200953
201102
200935
end
gen delivery = weekly(dates,"YW")
*************************
I get the result: (4 missing values generated) rather than the correct result.
I know that the 53-week year in 2009 is also going to pose a problem,
but this problem persists even in the absence of week 53.
I have also attempted to split the string into components and build
the dates from these, but I receive the same problem, that missing
values are generated rather than the values themselves:
******************
inp str06 dates
201002
200953
201102
200935
end
gen year =substr(dates,1,4)
encode year, generate(nyear)
gen week = substr(dates,5,2)
encode week, generate(nweek)
gen delivery2 = yw(nyear,nweek)
*********************************
Thanks for reading, and any help would be greatly appreciated.
Ruth Gilgenbach
*
* 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/