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]
Re: st: Collapsing daily data to a monthly data on the 15th each month
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Collapsing daily data to a monthly data on the 15th each month
Date
Tue, 21 Jan 2014 17:56:23 +0000
Let's identify each month by a start date that is 16th of each month
and each year.
The target starts are
gen target = date if day(date) == 16
Some surgery will needed at the beginning to enter an appropriate
target for observation 1 if the first day is not the 16th.
replace target = mdy(<month>, 16, <year>) in 1
Then we copy each target by
replace target = target[_n-1] if missing(target)
then -collapse ... , by(target)-
Nick
[email protected]
On 21 January 2014 17:42, Toby Knapen wrote:
> Dear Statalisters,
>
> I would like to transform my daily data to monthly data, calculated on
> the 15th of each month, more precisely, from the 16th day of a
> specific month up to and including the 15th day of the following
> month. The problem is that I can only find the way to this it based on
> 'regular' months. This can be done by using the following commands:
>
> g dm=mofd(date)
> format dm %tm
> collapse prc ret shrout vwretd ewretd, by (dm)
> tsset dm, monthly
>
> Since I'm having inflation dates on the 15th each month I would like
> to have the monthly data on the 15th as well, otherwise there will be
> a mismatch in my data. The data on my dates looks like below:
>
> 16dec2002
> 17dec2002
> 18dec2002
> 19dec2002
> 20dec2002
> 23dec2002
> 24dec2002
> 26dec2002
> 27dec2002
> 30dec2002
> 31dec2002
> 02jan2003
> 03jan2003
> 06jan2003
> 07jan2003
> 08jan2003
> 09jan2003
> 10jan2003
> 13jan2003
> 14jan2003
> 15jan2003
> 16jan2003
> 17jan2003
> 21jan2003
> 22jan2003
> 23jan2003
> 24jan2003
> 27jan2003
> 28jan2003
>
*
* 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/