string vector question

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

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

string vector question

Postby vytama » Fri Feb 27, 2015 11:33 am

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

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: string vector question

Postby trubador » Sat Feb 28, 2015 4:01 pm

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))


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 1 guest