Retrieving page frequency
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
Retrieving page frequency
Is there a way to retrieve the date frequency of a page?
Re: Retrieving page frequency
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 Developer
- Posts: 161
- Joined: Wed Sep 17, 2008 10:39 am
Re: Retrieving page frequency
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:
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 ':'.
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 Developer
- Posts: 161
- Joined: Wed Sep 17, 2008 10:39 am
Re: Retrieving page frequency
Here's another variant that doesn't depend on the global option settings for the frequency delimiter.
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
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
Re: Retrieving page frequency
Excellent, thank you all for your help.
Who is online
Users browsing this forum: No registered users and 17 guests