Page 1 of 1

Command IF inside the loop

Posted: Fri Nov 03, 2017 9:24 am
by a.do88
Hi

I used this command to report the coefficient and its pvalue of all equations in one table in column 1 and 2 and it works.

!row=1
!col=1
!col1=!col+0
!tabrow=24
for %i au
for %j au hk jp sg uk us
for %c c7
equation eq_{%i}_{%j}.arch(1,1, archm=sd, egarch, ged) {%i} c {%j}(-1)
freeze(table) eq_{%i}_{%j}
result_{%c}(!row,!col1) = @val(table(!tabrow,2))
result_{%c}(!row, !col1+1)=@val(table(!tabrow,5))
!row=!row+1
d table
d eq_{%i}_{%j}
next

Then I would like to set the !tabrow that would be automatically changed when I change the value in the variable %c.

So I add the command IF to this loop:
!row=1
!col=1
!col1=!col+0
for %i au
for %j au hk jp sg uk us
for %c c7
equation eq_{%i}_{%j}.arch(1,1, archm=sd, egarch, ged) {%i} c {%j}(-1)
freeze(table) eq_{%i}_{%j}
if %c = "c7" then !tabrow=24
!tabrow=1
endif

result_{%c}(!row,!col1) = @val(table(!tabrow,2))
result_{%c}(!row, !col1+1)=@val(table(!tabrow,5))
!row=!row+1
d table
d eq_{%i}_{%j}
next

Then I got N/A in my table.

Any comment/suggestion is greatly appreciated.

Re: Command IF inside the loop

Posted: Fri Nov 03, 2017 9:26 am
by EViews Gareth
This code has a few issues.

Code: Select all

for %c c7
This line creates a for loop with only one value. The loop is meaningless.

Code: Select all

if %c = "c7" then !tabrow=24 !tabrow=1 endif
This if condition is meaningless, since %c is always equal to "c7" (given your above for loop).

Plus the if condition changes the same thing twice.

Re: Command IF inside the loop

Posted: Sat Nov 04, 2017 5:58 pm
by a.do88
Thanks Gareth for your reply.

How about this command IF

The message is" NA found in matrix in IF{%i} = AU THEN"
!col=1
for %i au ger
if {%i} = au then !n = 0
else
!n = 1
endif
!col1=!col+2*!n
next

Your help is really appreciated.

Re: Command IF inside the loop

Posted: Sat Nov 04, 2017 7:06 pm
by EViews Gareth

Code: Select all

if %i = "au" then !n=0 else !n=1 endif