Page 1 of 1

period in a given frequency

Posted: Wed Jun 29, 2022 8:01 am
by tvonbrasch
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

Re: period in a given frequency

Posted: Wed Jun 29, 2022 8:36 am
by EViews Gareth
Not sure I follow.

Re: period in a given frequency

Posted: Thu Jun 30, 2022 6:36 am
by tvonbrasch
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

Re: period in a given frequency

Posted: Thu Jun 30, 2022 7:57 am
by EViews Gareth

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).

Re: period in a given frequency

Posted: Thu Jun 30, 2022 11:11 pm
by tvonbrasch
great, thanks!