Using Eviews 6 with the July 2010 build. I'm trying to run a loop to get rid of the NAs in a table, but the rows with the NAs aren't being deleted. The program runs, but nothing happens. The problem is in the second if loop where it doesn't recognize that the observations from 1975:1 to 1990:1 for {%a}ch and {%a}pch are all NAs. I tried doing it with {%chg_tab}(!i-1,2)=NA as well but that didn't work either.
%chg_tab=%a+"chg_tab"
table(@obssmpl,3) {%chg_tab}
smpl 1975:1 2017:4
!rowcounter=1
for !rowcounter=1 to @obssmpl
{%chg_tab}(!rowcounter,1) = @otod(!rowcounter)
{%chg_tab}(!rowcounter,2) = {%a}ch(!rowcounter)
{%chg_tab}(!rowcounter,3) = {%a}pch(!rowcounter)
!rowcounter = !rowcounter+1
next
for !i=2 to @obssmpl-1
if @isna({%chg_tab}(!i-1,2))=1 then
{%chg_tab}.deleterow(!i-1) 1
endif
!i = !i+1
next
{%spool}.append {%chg_tab}
Thanks
Deleting NAs from a table
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Deleting NAs from a table
Haven't tested this, but off the top of my head...
Tables don't store numbers. They store string representations of numbers. The @ISNA function works on numbers, not strings. Thus you can't use it to test the cell in a table. Try testing table(i,j)="NA" instead.
Tables don't store numbers. They store string representations of numbers. The @ISNA function works on numbers, not strings. Thus you can't use it to test the cell in a table. Try testing table(i,j)="NA" instead.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Deleting NAs from a table
Actually, that won't work either.
This will:
This will:
Code: Select all
!test = @val(table(!i,!j))
if @isna(!test) then
'blah
endif
Re: Deleting NAs from a table
Thanks very much. I had to make a slight adjustment to get it to work properly. I took out the !i's out of the val(!i,!j) and the deleterow(!i) and replace them with the first row, otherwise it would skip a line as it was going through the for-loop.
for !i=1 to @obssmpl
!test=@val({%chg_tab}(1,2))
if @isna(!test) then
{%chg_tab}.deleterow(1)
endif
next
Appreciate all the help, its making the programming much less frustrating.
for !i=1 to @obssmpl
!test=@val({%chg_tab}(1,2))
if @isna(!test) then
{%chg_tab}.deleterow(1)
endif
next
Appreciate all the help, its making the programming much less frustrating.
Who is online
Users browsing this forum: No registered users and 2 guests
