Page 1 of 1

sample every 30th observation from a series

Posted: Wed Jul 15, 2020 12:39 pm
by superjocker
Hi, I need to sample every 30th observation from a series starting from the last observation, this is if my last observation is on the 7/15/2020, then the 30th observation before that would be the 6/15/2020, and then 5/15/2020. I was trying to use dateadd but didnt work. I hope someone knows the answer.

Thanks

Re: sample every 30th observation from a series

Posted: Wed Jul 15, 2020 12:50 pm
by EViews Gareth
To be clear, you mean 7/15/2020, 6/15/2020 and 5/16/2020?

Oh, and what frequency is the workfile?

Re: sample every 30th observation from a series

Posted: Wed Jul 15, 2020 12:59 pm
by superjocker
my data is daily and have observations since 1989.

It doesnt matter if a month have 31 or 28 or 29, just need to substract 30 observations so yes 5/16/2020.

Thanks

Re: sample every 30th observation from a series

Posted: Wed Jul 15, 2020 1:07 pm
by EViews Gareth

Code: Select all

smpl if @mod(@trend,30)=28
This assumes that you have daily 7 data that starts on Jan 1st 1989. If the starting date is different, you'll have to change the "28" value. Just do:

Code: Select all

show @mod(@trend,30)
and see what the value is on 2020/07/15 and use that value in the sample.

Re: sample every 30th observation from a series

Posted: Wed Jul 15, 2020 1:43 pm
by superjocker
Thank you Gareth, it works perfectly.

Regards