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: creating a custom monthly date


From   Eric Booth <eric.a.booth@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: creating a custom monthly date
Date   Sat, 21 Apr 2012 12:25:48 -0500

<>

I'll reiterate my suggestion for -bcal- then since you can set what are considered business days (and adjust for days of the week and holidays that affect those days).  

- Eric

__
Eric A. Booth
Public Policy Research Institute 
Texas A&M University
ebooth@ppri.tamu.edu
+979.845.6754


On Apr 21, 2012, at 11:35 AM, Francesco wrote:

> Dear Eric,
> 
> Your suggestion is really fine, but I still have some problems :
> 
> Let me first explain more clearly my decision rule : The daily dates
> in my dataset are european trading days, and I need to create a custom
> month variable that do not perfectly overlap with the current month.
> For example, let us take January 2012, I would like to create a
> variable month_special which is "February 2012" starting from January
> 26th onwards... and will be March 2012 as soon as the daily date is
> greater that February 24th (a friday), and so on.... That is: the next
> month_special starts exactly 3 business days before the last day of
> any given month...
> 
> Do you have an idea?
> Many thanks, again,
> 
> Best,
> 
> 
> 
> On 21 April 2012 15:58, Francesco <cariboupad@gmx.fr> wrote:
>> Many thanks Eric for your kind suggestion,
>> I will try it right now!
>> 
>> Have a nice day,
>> Best
>> 
>> On 21 April 2012 15:46, Eric Booth <eric.a.booth@gmail.com> wrote:
>>> <>
>>> 
>>> Sounds like it could be a job for -help bcal-.
>>> I'm not sure that I fully understand your decision rules for creating the custom month, but this might get you started without -bcal-:
>>> 
>>> *******************!
>>> clear
>>> set obs 10000
>>> g date = 15000+runiform()*800 //fake dates
>>> format date %td
>>> duplicates report
>>> 
>>> gen month = month(date)
>>> 
>>> clonevar month_new = month
>>> replace month_new = month-1 if  ///
>>>        month(date-2)<month(date) | month(date-1)<month(date) & inrange(dow(date-2), 1, 5)
>>> replace month_new = month+1 if  ///
>>>        month(date+3)>month(date) | month(date+2)>month(date) | month(date+1)>month(date)
>>> g flag = month_new!=month
>>> l if day(date)<2 & flag //check
>>> *******************!
>>> 
>>> - Eric
>>> 
>>> __
>>> Eric A. Booth
>>> Public Policy Research Institute
>>> Texas A&M University
>>> ebooth@ppri.tamu.edu
>>> Office: +979.845.6754
>>> 
>>> 
>>> On Apr 21, 2012, at 7:56 AM, Francesco wrote:
>>> 
>>>> Dear Statalist,
>>>> 
>>>> I have a little problem about the creation a custom date in Stata 12.
>>>> 
>>>> Let me specify what I would like to do : I have a panel dataset with
>>>> daily observations (which may contains multiple identical dates for
>>>> the same id)
>>>> I already know how to obtain the relevant month for each daily date,
>>>> by typing -gen month=mofd(daily_date).
>>>> 
>>>> However, please do not ask me why, I absolutely need to create a
>>>> "custom" month variable that starts 2 days before the end of the
>>>> previous month (in terms of working days) and ends 3 days before the
>>>> start of the next month... I need a way to do that which I can
>>>> reproduce accross different datasets, thus obtaining the same custom
>>>> dates (for a merging purpose)...
>>>> 
>>>> What do you think?
>>>> Could you help me ?
>>>> 
>>>> Many thanks
>>>> *
>>>> *   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/
>>> 
>>> 
>>> *
>>> *   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/
> 
> *
> *   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/


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