Hi, I am trying to sample the last day of each month in a daily series. is there a way to do it?
Thanks
last day of a month
Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13307
- Joined: Tue Sep 16, 2008 5:38 pm
Re: last day of a month
Follow us on Twitter @IHSEViews
-
- Posts: 27
- Joined: Mon Mar 30, 2020 5:45 pm
Re: last day of a month
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
Thanks
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13307
- Joined: Tue Sep 16, 2008 5:38 pm
Re: last day of a month
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
-
- Posts: 27
- Joined: Mon Mar 30, 2020 5:45 pm
Re: last day of a month
Yes, thank you, it works.
Regards
Regards
-
- Posts: 27
- Joined: Mon Mar 30, 2020 5:45 pm
Re: last day of a month
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
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
Who is online
Users browsing this forum: No registered users and 18 guests