Retrieving page frequency

For questions regarding programming in the EViews programming language.

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

abielr
Posts: 9
Joined: Wed Feb 04, 2009 12:25 pm

Retrieving page frequency

Postby abielr » Tue May 05, 2009 11:32 am

Is there a way to retrieve the date frequency of a page?

trubador
Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

Re: Retrieving page frequency

Postby trubador » Wed May 06, 2009 12:26 am

I am not sure if EViews has a command for this or there is another way to obtain it as a shortcut. But assuming that you have a structured workfile, the following long-winded code should serve the purpose for the time being.

Code: Select all

pageselect page1 '(optional)
series y = @date
series dy = d(y)
table(1,1) freq

!i=@max(dy)

if !i=1 then %freq = "Daily - 7 day week"
  else if !i=3 then %freq = "Daily -5 day week"
    else if !i=7 then %freq = "Weekly"
      else if !i=31 then %freq = "Monthly"
        else if !i=92 then %freq = "Quarterly"
          else if !i=184 then %freq = "Semi-annual"
            else if !i=366 then %freq = "Annual"
            endif
          endif
        endif
      endif
    endif
  endif
endif

freq(1,1) = %freq
show freq

delete y dy

EViews Chris
EViews Developer
Posts: 161
Joined: Wed Sep 17, 2008 10:39 am

Re: Retrieving page frequency

Postby EViews Chris » Wed May 06, 2009 11:57 am

Trubador's approach is interesting, but is not guaranteed to work for all workfiles. (The problem is that it relies on the range of the workfile being large enough so that the maximum difference in @date is observed within the workfile range. In the limiting case of only one observation in the workfile, no differences of @date can be calculated at all).

With one caveat, the following approach is generally more reliable:

Code: Select all

%freq = @datestr(@now,"F")


I've used @now here as the first argument, but any date will return the same value in %freq.

The values returned in %freq are:
'A' -> annual
'S' -> semiannual
'Q' -> quarterly
'M' -> monthly
'W' -> weekly
'B' -> mon-fri daily ('b' is for business day)
'D' -> daily
'?' -> undated

See the bottom of p. 711 of the User's Guide for why this works.

The caveat is that this only works if the global option setting for 'Quarterly/Monthly display' is set to 'Frequency Delimiter'. Otherwise %freq will always be set to ':'.

EViews Chris
EViews Developer
Posts: 161
Joined: Wed Sep 17, 2008 10:39 am

Re: Retrieving page frequency

Postby EViews Chris » Wed May 06, 2009 2:19 pm

Here's another variant that doesn't depend on the global option settings for the frequency delimiter.

Code: Select all

!p = @datepart(@dateval("2001-12-31"), "p")


This will put the number of workfile periods in the year 2001 into the variable !p. You should get the following values for different frequencies:

1 = annual
2 = semiannual
4 = quarterly
12 = monthly
52 = weekly (could also be 53 depending which day of the week the workfile starts on)
261 = 5 day daily
365 = 7 day daily

abielr
Posts: 9
Joined: Wed Feb 04, 2009 12:25 pm

Re: Retrieving page frequency

Postby abielr » Wed May 06, 2009 4:04 pm

Excellent, thank you all for your help.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 17 guests