I'm wondering if there's a way to validate a series type. I'm thinking of checking whether a series is numerical or alpha. And if it is alpha, I would add an error message in a table I'm creating such as "This is an alpha series" and have the loop move to the next series before calculating the percentage difference (as that will result in an error).
Here's what I have so far:
Code: Select all
'create table + setup
!row = 2
table aresults
aresults(1, 1) = "Series"
aresults(1, 2) = "Year"
aresults(1, 3) = "Old Value"
aresults(1, 4) = "New Value"
aresults(1, 5) = "% Difference"
aresults(1, 6) = "Comments"
'''''''''''''''''''''''''''''''''''''''''''''''
' LOOP '
'''''''''''''''''''''''''''''''''''''''''''''''
'loops through series list
for !j=1 to chgename.@count
%seriesnam = chgename.@seriesname(!j)
'check if series is an alpha series
if {%seriesnam}.@type == "alpha" then
'comments
aresults(!row, 6) = "Series is an alpha series."
'increment row
!row = !row + 1
'move to next series
%seriesnam = chgename.@seriesname(!j + 1)
endif
'calculates percentdiff for the last 10 years
smpl @last-9 @last
%seriesnam = chgename.@seriesname(!j)
series b{%seriesnam} = @abs(({%seriesnam}_01 - {%seriesnam}) / (({%seriesnam} + {%seriesnam}_01) / 2)) * 100
...
