Page 1 of 1

Using strings in FOR Loop (Eviews 7)

Posted: Tue Oct 29, 2013 9:21 am
by bjammin
Hello,

I am trying to loop through a set of variables to set up a group for each permutation of up to a certain number of variables (2 in this example). I would also like to set it up so that I do not create groups for the same variables in different orders. The code that I have so far is this:

Code: Select all

for !i=1 to indicators.@count for !g=1 to indicators.@count %reg1=indicators.@seriesname(!i) %reg2=indicators.@seriesname(!g) %regs=%reg1 + " " + %reg2 %regs=@wunique(%regs) %regs=@wsort(%regs) %name1="!i" %name2="!g" %rname=%name1 + " " + %name2 %rname=@wunique(%rname) %rname=@wsort(%rname) %regname="z_" + @replace(%rname," ","") group {%regname} {%regs} next next
What I am trying to do is assign a number to each variable to put in the group name, then sort by those numbers so that if the group contains the same variables it will overwrite the previous group and won't leave me with a double. However, I'm pretty sure the @wunique and @wsort functions are reading this as "!g" and "!i" instead of the numbers. Is there a way around this, or am I just setting it up wrong? Thanks.

Re: Using strings in FOR Loop (Eviews 7)

Posted: Tue Oct 29, 2013 9:32 am
by EViews Gareth
I think you probably want %name = @str(!i)

Re: Using strings in FOR Loop (Eviews 7)

Posted: Tue Oct 29, 2013 9:34 am
by bjammin
Excellent, thanks!