sample every 30th observation from a series

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

superjocker
Posts: 27
Joined: Mon Mar 30, 2020 5:45 pm

sample every 30th observation from a series

Postby superjocker » Wed Jul 15, 2020 12:39 pm

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13319
Joined: Tue Sep 16, 2008 5:38 pm

Re: sample every 30th observation from a series

Postby EViews Gareth » Wed Jul 15, 2020 12:50 pm

To be clear, you mean 7/15/2020, 6/15/2020 and 5/16/2020?

Oh, and what frequency is the workfile?
Follow us on Twitter @IHSEViews

superjocker
Posts: 27
Joined: Mon Mar 30, 2020 5:45 pm

Re: sample every 30th observation from a series

Postby superjocker » Wed Jul 15, 2020 12:59 pm

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13319
Joined: Tue Sep 16, 2008 5:38 pm

Re: sample every 30th observation from a series

Postby EViews Gareth » Wed Jul 15, 2020 1:07 pm

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.
Follow us on Twitter @IHSEViews

superjocker
Posts: 27
Joined: Mon Mar 30, 2020 5:45 pm

Re: sample every 30th observation from a series

Postby superjocker » Wed Jul 15, 2020 1:43 pm

Thank you Gareth, it works perfectly.

Regards


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 23 guests