Using strings in FOR Loop (Eviews 7)

For questions regarding programming in the EViews programming language.

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

bjammin
Posts: 3
Joined: Mon Oct 28, 2013 3:20 pm

Using strings in FOR Loop (Eviews 7)

Postby bjammin » Tue Oct 29, 2013 9:21 am

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.

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

Re: Using strings in FOR Loop (Eviews 7)

Postby EViews Gareth » Tue Oct 29, 2013 9:32 am

I think you probably want %name = @str(!i)

bjammin
Posts: 3
Joined: Mon Oct 28, 2013 3:20 pm

Re: Using strings in FOR Loop (Eviews 7)

Postby bjammin » Tue Oct 29, 2013 9:34 am

Excellent, thanks!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests