period in a given frequency

For questions regarding programming in the EViews programming language.

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

tvonbrasch
Posts: 540
Joined: Fri Apr 15, 2011 5:35 am

period in a given frequency

Postby tvonbrasch » Wed Jun 29, 2022 8:01 am

Hi,

How can I find the start-period that is used in the current sample?

For example, when using the commands

Code: Select all

smpl 2020:3 2020


on a dated workfile on a quarterly, monthly, weekly, or daily frequency, I want to fetch the period "3" of that current sample. How can I do this in a robust way?

I believe I can use the command on a quarterly frequency:

Code: Select all

%tmp = @otods(1)
!start = @datepart(@dateval(%tmp), "Q")


but it does not work well on other frequencies. Any suggestions for a robust code that works across different frequencies?
Thomas

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

Re: period in a given frequency

Postby EViews Gareth » Wed Jun 29, 2022 8:36 am

Not sure I follow.
Follow us on Twitter @IHSEViews

tvonbrasch
Posts: 540
Joined: Fri Apr 15, 2011 5:35 am

Re: period in a given frequency

Postby tvonbrasch » Thu Jun 30, 2022 6:36 am

Hi,

I am interested in the week number, month or quarter of the first observation in the current smpl. for example, in the following I want the scalar !startf to show the number 3 at all frequencies:

Code: Select all

for %f q m w
   wfcreate(wf=1) {%f} 2015 2025
   smpl 2020:3 2020
      %tmp = @otods(1)
      %startf=@mid(%tmp, 6)
      !startf=@val(%startf)
      scalar a{%f} = !startf
      show a{%f}
next


but this does not work for the weekly frequency. how can I write this so that it becomes robust across frequencies?
t

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

Re: period in a given frequency

Postby EViews Gareth » Thu Jun 30, 2022 7:57 am

Code: Select all

%freqtype = %f + %f
if %f="q" then
      %freqtype = "q"
endif
     
!startf = @datepart(@dateval(%tmp), %freqtype)



Datepart works, its just annoying that the frequency string doesn't match exactly (date functions use "ww" and "mm" for weekly and monthly, respectively).
Follow us on Twitter @IHSEViews

tvonbrasch
Posts: 540
Joined: Fri Apr 15, 2011 5:35 am

Re: period in a given frequency

Postby tvonbrasch » Thu Jun 30, 2022 11:11 pm

great, thanks!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 10 guests