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 on April 23, and its replacement, statalist.org is already up and running.


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

st: defining a generic date variable with occasional 53-week years


From   "Dimitriy V. Masterov" <dvmaster@gmail.com>
To   Statalist <statalist@hsphsun2.harvard.edu>
Subject   st: defining a generic date variable with occasional 53-week years
Date   Thu, 22 Jul 2010 10:56:21 -0400

I am working with a dataset where I am forced to use a peculiar
calendar system: some years have 53 weeks. This means that the %tw
format does not always work. I've been using the following hack to get
around this:

egen time = concat(year week), p(w);
sencode time, replace;
format time %tg;

Unfortunately this is not ideal because different datasets cover
different periods, so time==1 will refer to different dates in
different datasets. This makes merging by time difficult.

Is there a way to construct a generic date variable from
numerical/string components that would alllow for dates like 2009w53,
but with a constant base period? Or is there another way to deal with
this problem?

Dimitriy
*
*   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/


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