summing available daily observations to monthly

For questions and discussion related to reading in and working with data.
tclark
Posts: 97
Joined: Wed Nov 08, 2006 3:20 pm

summing available daily observations to monthly

Unread post by tclark »

Following other work in a literature, I would like to read in data that are daily at a limited number of dates (these come from an event study approach to constructing monetary policy shocks) to create monthly series that sum the available observations within a month and contains zeros for months with no higher frequency source observations. Consistent with what the reference manual describes, using a monthly calendar with compact=sum does not deliver this outcome (among other issues, it repeats observations across months). Is there some other way to do it? I have attached the source data in question along with a compact=sum approach that does not work as desired. Thanks much.
Attachments
MPshocks.xlsx
(17.53 KiB) Downloaded 70 times
test.prg
(227 Bytes) Downloaded 72 times
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
TomDoan
Posts: 7728
Joined: Wed Nov 01, 2006 4:36 pm

Re: summing available daily observations to monthly

Unread post by TomDoan »

RATS tries to guess the date scheme in the input data and (here) doesn't do a very good job of it. However, it will work if you force it to recognize the input data as daily:

Code: Select all

cal(d,save=forcedaily) 1990:1:1
cal(m) 1990:1
comp stsmpl=1990:1, endsmpl=2019:12
all endsmpl
smpl stsmpl endsmpl

open data MPshocks.xlsx
data(format=xlsx,org=col,compact=sum,calendar=forcedaily) / FFRfactor FGfactor LSAPfactor
close data
Note that you'll get NA's for any month with no data, but that will be easy to patch over.
tclark
Posts: 97
Joined: Wed Nov 08, 2006 3:20 pm

Re: summing available daily observations to monthly

Unread post by tclark »

Fantastic -- thanks very much!
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
Post Reply