I am try to automate some computation with transformation of series names.
The problem that I have is that the temporary variable used as counter in the loop does not allow me to loop over lists of characters.
I come from MATLAB, so my way of doing things may not be the most appropriate for EVIEWS.
The code under does the following:
1) generate random series
2) generate names objects (one short name, one long)
3) Loop over the potential variable name and execute a simple expression
Code: Select all
wfcreate(wf=annual, page=myproject) a 1950 2005
genr series1=nrnd
genr series2= 0.9*series1(-1)+ 0.1*nrnd
alpha shortnames
shortnames(1) = "short1"
shortnames(2) = "short2"
alpha longnames
longnames(1) = "series1"
longnames(2) = "series2"
group grouptest
for !i=1 to 2 ' loop over the variables
%stringtemp=shortnames(!i) 'create temporary variable for the short name
%stringtemp2=longnames(!i) 'create temporary variable for the long name
for !j=1 to 2
series test{%stringtemp}{!j}= {%stringtemp2} - !i + 10*!j
grouptest.add test{%stringtemp}{!j}
next
next
grouptest.line(m)
‘The series testXXX should be testshort11 and not testseries11
The expected behavior should be the following:
a series testshort11 which would take the values of series1 - 1 +10
a series testshort12 which would take the values of series1 - 1 +20
a series testshort21 which would take the values of series2 - 2 +10
a series testshort22 which would take the values of series2 - 2 +20
Instead, the names of the series created remain testseriesXX. I suspect that Eviews does not handle two temporary variables at the same time (%stringtemp and %stringtemp2).
Thanks in advance for the help you can provide.