last day of a month

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

last day of a month

Postby superjocker » Tue Jul 14, 2020 12:27 pm

Hi, I am trying to sample the last day of each month in a daily series. is there a way to do it?

Thanks

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

Re: last day of a month

Postby EViews Gareth » Tue Jul 14, 2020 12:29 pm

Code: Select all

smpl if @month<>@month(1)


(i.e. if the month doesn't equal tomorrow's month)
Follow us on Twitter @IHSEViews

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

Re: last day of a month

Postby superjocker » Tue Jul 14, 2020 12:53 pm

Thanks, you know it all. I have another question, how do you get the returns for a month, taking into account that some months have 31 days, others 30 and some 28 or 29?

Thanks

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

Re: last day of a month

Postby EViews Gareth » Tue Jul 14, 2020 1:31 pm

I think I would build an index series, that resets to 100 on the first of the month, and compounds the daily returns, then compute the return based on the value of the index at the end of the month. Something like (and this is off the top of my head, so might need adjustment):

Code: Select all

series index = @recode(@day=1, 100, index(-1)*(1+return))
series monthreturn = @recode(@month<>@month(1), index/100, na)
Follow us on Twitter @IHSEViews

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

Re: last day of a month

Postby superjocker » Wed Jul 15, 2020 7:51 am

Yes, thank you, it works.

Regards

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

Re: last day of a month

Postby superjocker » Wed Jul 15, 2020 11:05 am

I made some changes to part of your code to make it work, here it is in case anybody needs it.

series return1 = @recode(@month<>@month(1), stockprice, na)
series return2= @recode(return1=na, return2(-1), return1)
series return3=(return2-return2(-1))/return2(-1)
series return4 = @recode(@month<>@month(1), return3, na)

then delete return 1, 2 y 3 and sample
smpl if @month<>@month(1)

thank you


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 18 guests