Replace Variables Problem

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

Ralph
Posts: 1
Joined: Wed Nov 12, 2008 7:34 pm

Replace Variables Problem

Postby Ralph » Wed Nov 12, 2008 8:21 pm

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13313
Joined: Tue Sep 16, 2008 5:38 pm

Re: Replace Variables Problem

Postby EViews Gareth » Thu Nov 13, 2008 12:30 am

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.
Follow us on Twitter @IHSEViews

lomazzi
Posts: 1
Joined: Tue Jan 13, 2009 7:17 am

Re: Replace Variables Problem

Postby lomazzi » Tue Jan 13, 2009 7:28 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13313
Joined: Tue Sep 16, 2008 5:38 pm

Re: Replace Variables Problem

Postby EViews Gareth » Tue Jan 13, 2009 9:06 am

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
Follow us on Twitter @IHSEViews

farrel
Posts: 108
Joined: Thu Sep 18, 2008 11:13 pm

Re: Replace Variables Problem

Postby farrel » Sat Jun 27, 2009 1:19 am

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"

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13313
Joined: Tue Sep 16, 2008 5:38 pm

Re: Replace Variables Problem

Postby EViews Gareth » Sat Jun 27, 2009 8:05 am

Code: Select all

table vars

for !i=1 to 100
vars(!i,1) = "something"+@str(!i)
next
Follow us on Twitter @IHSEViews

farrel
Posts: 108
Joined: Thu Sep 18, 2008 11:13 pm

Re: Replace Variables Problem

Postby farrel » Sun Jun 28, 2009 12:53 pm

thanks


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 15 guests