@month but for weekly?

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

amrsherif
Posts: 105
Joined: Mon Jul 23, 2018 4:34 pm

@month but for weekly?

Postby amrsherif » Tue Oct 08, 2024 2:10 pm

Hi,

I am trying to create a weekly series (with 52 observations) where each week's obs is the median of the same week during the past 20 years.
I can do it in monthly as below:

for !i=1 to 12
series s1{!i}=@recode(@month={!i},s1,na) 'create 12 parallel series dropping all values but a specific month, for all years
next

for !i= 1 to 12
series output=@recode(@month={!i},@median(s1{!i}), output)
next


Is there anything similar (or any other suggestions) for weekly?

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

Re: @month but for weekly?

Postby EViews Gareth » Tue Oct 08, 2024 3:12 pm

What frequency is your workfile?
Follow us on Twitter @IHSEViews

amrsherif
Posts: 105
Joined: Mon Jul 23, 2018 4:34 pm

Re: @month but for weekly?

Postby amrsherif » Tue Oct 08, 2024 4:33 pm

I am in a weekly workfile.

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

Re: @month but for weekly?

Postby EViews Gareth » Tue Oct 08, 2024 4:48 pm

Code: Select all

'monthly series output_m = @mediansby(s1, @month) 'weekly series output_w = @mediansby(s1, @datepart(@date, "ww"))

(in answer to your question, since weeks aren't really defined in any frequency other than weekly, the @datepart(@date, "ww") function represents "@week")
Follow us on Twitter @IHSEViews

amrsherif
Posts: 105
Joined: Mon Jul 23, 2018 4:34 pm

Re: @month but for weekly?

Postby amrsherif » Wed Oct 09, 2024 8:21 am

Never used @mediansby before.
Thank you. Very helpful!


Return to “Programming”

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests