Using strings to name variables
Posted: Wed Mar 30, 2011 3:57 pm
I'm writing a global subroutine to which I have sent, among other things, a GROUP that the subroutine brings in as 'data'. I would like to use the names of the series in the group as strings, and concatenate those strings with other strings to call other series that are not in the group (but have similar names) and do calculations on them. Imagine there are only 2 series in 'data' and they're called SERIESA and SERIESB. My intention with this loop is to calculate
so that I am using the name SERIESA to call QSERIESA as well. I wrote the code this way but it doesn't work; the error message states that Eviews "can not assign string expression to numeric variable...." :
I'm probably making several different mistakes all at once but could you please explain what I need to do to differently? Thanks very much for your help.
Code: Select all
( @pca(QSERIESA) * SERIESA(-1) / AGGREGATE(-1) ) + ( @pca(QSERIESB) * SERIESB(-1) / AGGREGATE(-1) ) Code: Select all
for !x = 1 TO data.@count
SERIES laspq = laspq + (@pca("q"+data.@seriesname(!x)) * data.@seriesname(!x)(-1) / aggregate(-1))
next