Delete blank rows in alpha series

For questions regarding programming in the EViews programming language.

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

chester
Posts: 44
Joined: Thu May 12, 2016 11:14 am

Delete blank rows in alpha series

Postby chester » Thu Nov 17, 2016 9:00 am

I'm simply trying to remove blank rows in my alpha series called 'uniquegroups'.
What is wrong with this approach?

Code: Select all

for !i=1 to @obsrange if uniquegroups(!i) = "" then delete uniquegroups(!i) endif next

EViews Matt
EViews Developer
Posts: 584
Joined: Thu Apr 25, 2013 7:48 pm

Re: Delete blank rows in alpha series

Postby EViews Matt » Thu Nov 17, 2016 11:37 am

Hello,

The delete command removes entire objects, not individual observations. In addition, the length of an alpha series is dependent on the workfile page's observations, so you cannot "shorten" the alpha series without removing observations from the workfile page. If that's what you want, to affect the entire page, then take a look at the pagecontract command.

Considering your prior thread on a related topic, I'm guessing you still just want some kind of list of all the unique elements (excluding blanks) in an alpha series. Here's another solution that may be of greater use to you:

Code: Select all

svector uniques = @uniquevals(@convert(alpha, "if alpha <> """""))
where "alpha" is the name of the alpha series. The call to @convert generates an svector containing the non-blank elements of the alpha series, which is then filtered by @uniquevals to extract only the unique elements. Note that an svector is used to hold the subset of elements from the alpha series because the length of an svector is independent of the workfile page's observations.
Last edited by EViews Matt on Thu Dec 01, 2016 5:17 pm, edited 2 times in total.

chester
Posts: 44
Joined: Thu May 12, 2016 11:14 am

Re: Delete blank rows in alpha series

Postby chester » Thu Nov 17, 2016 12:04 pm

Hello,

The delete command removes entire objects, not individual observations. In addition, the length of an alpha series is dependent on the workfile page's observations, so you cannot "shorten" the alpha series without removing observations from the workfile page. If that's what you want, to affect the entire page, then take a look at the pagecontract command.

Considering your recent previous thread on a similar topic, I'm guessing you still just want some kind of list of all the unique elements (excluding blanks) in an alpha series. Here's another solution that may be of greater use to you:

Code: Select all

svector uniques = @uniquevals(@convert(alpha, "if @length(alpha) > 0"))
where "alpha" is the name of the alpha series. The call to @convert generates an svector containing the non-blank elements of the alpha series, which is then filtered by @uniquevals to extract only the unique elements. Note that an svector is used to hold the subset of elements from the alpha series because the length of an svector is independent of the workfile page's observations. And FYI, I've used the conditional sample shown above instead of the more intuitive "if alpha <> """ to avoid an issue with nested quotes in strings.
That makes a lot of sense. I just added the '@convert' part to my existing alpha series 'uniquegroups'. Thanks Matt!
Now related to this, is there a way to alphabetically sort an alpha series (and not the entire workfile?).

EViews Matt
EViews Developer
Posts: 584
Joined: Thu Apr 25, 2013 7:48 pm

Re: Delete blank rows in alpha series

Postby EViews Matt » Thu Nov 17, 2016 2:25 pm

I'm not aware of any way to sort an alpha series without affecting the rest of its page. I believe you'll need to copy the data to a new page, sort it there, and then copy it back. For example:

Code: Select all

%originalPage = @pagename pagecopy(page=tmp) alpha sort alpha copy alpha {%originalPage}\alpha pagedelete tmp
Last edited by EViews Matt on Thu Nov 17, 2016 3:34 pm, edited 1 time in total.

chester
Posts: 44
Joined: Thu May 12, 2016 11:14 am

Re: Delete blank rows in alpha series

Postby chester » Thu Nov 17, 2016 2:38 pm

I'm not aware of any way to sort a series without affecting the rest of its page. I believe you'll need to copy the data to a new page, sort it there, and then copy it back. For example:

Code: Select all

%originalPage = @pagename pagecopy(page=tmp) alpha sort alpha copy alpha {%originalPage}\alpha pagedelete tmp
Hmmm, okay. That might be a little more trouble than its worth. Thank you for your help!

EViews Jason
EViews Developer
Posts: 870
Joined: Tue Sep 16, 2008 3:50 pm

Re: Delete blank rows in alpha series

Postby EViews Jason » Thu Nov 17, 2016 3:37 pm

You can currently only do it via the user interface and not via command. In the next patch, there will be a 'sort' proc for alpha series.

Usage will be the same as
http://www.eviews.com/help/helpintro.ht ... 23ww204355


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests