Page 1 of 1

string vector question

Posted: Fri Feb 27, 2015 11:33 am
by vytama
Hello,

Eviews 8 here. I have string vector with 15 names. I want to drop 2 names (based on certain criteria) from this svector and create new svector (13) with the rest of the names. I used If statement and it correctly identifies the names (let's say 5th and 10th) that I want to drop but when the code creates new svector it leaves rows 5 and 10 blank for dropped names. How can I bypass the empty rows and svector would move lower names into empty rows?

Here is the simple loop that I used:

!lead=@columns(TIME1) '13columns
!all=@rows(all) '15 rows
svector(!lead) svec

for !i=1 to !iall
if test(!i)=0 or test(!i)<0 then

svec(!i)=all(!i)

endif
next

Re: string vector question

Posted: Sat Feb 28, 2015 4:01 pm
by trubador
I am not sure if there is a shortcut to pull out the elements of a svector as a string, but the following should do trick for you:

Code: Select all

%slist = "" %drop = "" for !i = 1 to @rows(svec) %slist = %slist + " " + svec(!i) if test(!i)=0 or test(!i)<0 then %drop = %drop + " " + svec(!i) endif next svector svec = @wsplit(@wdrop(%slist,%drop))