replacement variable with string

For questions regarding programming in the EViews programming language.

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

vytama
Posts: 72
Joined: Wed Dec 19, 2012 11:05 am

replacement variable with string

Postby vytama » Wed Jul 27, 2016 9:20 am

Hello,

Eviews 9 here. I am trying to remove blank rows from svector. If I use equation below with single variable, it works fine.

%slist = ""
%drop = ""
for !i = 1 to @rows(mnemonic_sect_h)

%slist = %slist + " " + mnemonic_sect_h(!i)
if AA(!i)>0 and value( !i)<0.301 then
%drop = %drop + " " + mnemonic_sect_h(!i)
endif
next

But if I replace h with replacement variable %sect "h" "cc" "f" "h" "lm" "mp" "s" - it stops working:

for %sect "h" "cc" "f" "h" "lm" "mp" "s"
%slist_{%sect} = ""
%drop_{%sect} = ""
for !i = 1 to @rows(mnemonic_sect)
%slist_{%sect} = %slist_{%sect} + " " + mnemonic_sect_{%sect}(!i)
if AA(!i)>0 and value( !i)<0.301 then
%drop_{%sect} = %drop_{%sect} + " " + mnemonic_sect_{%sect}(!i)
endif
next
next
Where is the mistake with replacement variable? Thanks

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

Re: replacement variable with string

Postby EViews Gareth » Wed Jul 27, 2016 9:48 am

Code: Select all

for %sect h cc f h lm mp s

vytama
Posts: 72
Joined: Wed Dec 19, 2012 11:05 am

Re: replacement variable with string

Postby vytama » Wed Jul 27, 2016 10:08 am

I have tried your suggestion and it still does not work - gives me blank svectors for each of h cc f h lm mp s.

for %sect h cc f h lm mp s
'delete mnemonic_sect_{%sect}1
%slist_{%sect} = ""
%drop_{%sect} = ""
for !i = 1 to @rows(mnemonic_sect)

%slist_{%sect} = %slist_{%sect} + " " + mnemonic_sect_{%sect}(!i)
if AA(!i)>0 and value( !i)<0.301 then
%drop_{%sect} = %drop_{%sect} + " " + mnemonic_sect_{%sect}(!i)
endif
next
svector mnemonic_sect_{%sect}1= @wsplit(@wdrop(%slist,%drop))
next


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests