Page 1 of 1

summing available daily observations to monthly

Posted: Wed Jun 11, 2025 7:46 am
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.

Re: summing available daily observations to monthly

Posted: Wed Jun 11, 2025 12:01 pm
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.

Re: summing available daily observations to monthly

Posted: Wed Jun 11, 2025 5:34 pm
by tclark
Fantastic -- thanks very much!