Page 1 of 1

Nesting replacement variables

Posted: Tue Nov 04, 2014 10:47 am
by mamo
Dear followers,

I found that replacement variables can be nested, and I would like to share my finding here.
I use Eviews 8; however the trick should be applicable with earlier (later) versions as well.
'---
%v1="v2"
%v2="v3"
series v3=100
'--
%v1 refers to the contents of the string variable %v1: "v2"
%{%v1} refers to the contents of the string variable %v2: "v3"
{%{%v1} } refers to the object with the name v3, i.e. the series v3

possible pseudo application
'---
%groups="gr1 gr2 gr3"
%gr1_m="m11 m12 m13"
%gr2_m="m21 m22 m23 m34"
%gr3_m="m31 m32"
for %gr {%groups}
for %grm {%{%gr}_m}
' Do something with m[ij], as referred to by %grm
next
next
'---
I also found that nesting by more than two levels is feasable, i.e.: {%{%{%v1}}},
but nesting by more than two levels may be of less relevance in practical applications.

Best, mamo

Re: Nesting replacement variables

Posted: Tue Nov 04, 2014 10:54 am
by EViews Gareth
This isn't possible pre-EViews 7.1, I believe.