Page 1 of 1

Replace Variables Problem

Posted: Wed Nov 12, 2008 8:21 pm
by Ralph
Hello, everyone:
I'm wondering if a replace variable can refer to another replace variable in Eviews?
for example

create u 50
series x = nrnd
%var1 = "x" 'here I use a replace variable to refer series x
!k = 1 'here I use a control variable as index
My question is how can I create a replace variable %xvar to refer series x THROUGH %var and !k ???
I tried a couple of ways to work it out but they don't work such as

%xvar = "%var" + @str({!k}) 'here I create a string to represent replace variable %var1
series y = {%xvar} 'it doesn't work
or series y = {{%xvar}} 'it doesn't work either

we can do this kind of "double reference" easily in SAS, but I don't know whether Eviews can really do that or not.

regards
Ralph

Re: Replace Variables Problem

Posted: Thu Nov 13, 2008 12:30 am
by EViews Gareth
I don't believe you can use a replacement variable to refer to a replacement variable like that, no.

That doesn't mean there isn't a way to do what you want. Unfortunately I can't quite follow what it is you're trying to do, so can't offer any advice on how to do it.

Re: Replace Variables Problem

Posted: Tue Jan 13, 2009 7:28 am
by lomazzi
I have a similar problem and I tried several things

!loopmax=22

%1 = "OBLICHFDOM"'

for !loop=1 to !loopmax

show %!loop (This does not work)

next

Re: Replace Variables Problem

Posted: Tue Jan 13, 2009 9:06 am
by EViews Gareth
As said above, you can't combine replacement variables like that, nor can you refer to a replacement variable with a replacement variable.

I assume you have something like this:

%1 = "OBLICHFDOM"
%2 = "Something"
%3 = "Something else"

and then want to loop through them with a numerical variable.

The easiest way to do this is to not loop through them with a numerical variable, but with a string variable:

Code: Select all

for %i "oblichfdom" "something" "something else" statusline %i next

Or, if you really want to use a numerical variable in your for loop, then put the text into a table:

Code: Select all

table vars vars(1,1) = "oblichdom" vars(2,1) = "something" vars(3,1) = "something else" for !i=1 to 3 %var = vars(!i,1) statusline %var next

Re: Replace Variables Problem

Posted: Sat Jun 27, 2009 1:19 am
by farrel
But what I have to do if I want to make a lot of similar names in cells of table like this:

table vars
vars(1,1) = "something1"
vars(2,1) = "something2"
vars(3,1) = "something3"
....
vars(100,1) = "something100"

Re: Replace Variables Problem

Posted: Sat Jun 27, 2009 8:05 am
by EViews Gareth

Code: Select all

table vars for !i=1 to 100 vars(!i,1) = "something"+@str(!i) next

Re: Replace Variables Problem

Posted: Sun Jun 28, 2009 12:53 pm
by farrel
thanks