Page 1 of 1

Delete blank rows in alpha series

Posted: Thu Nov 17, 2016 9:00 am
by chester
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

Re: Delete blank rows in alpha series

Posted: Thu Nov 17, 2016 11:37 am
by EViews Matt
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.

Re: Delete blank rows in alpha series

Posted: Thu Nov 17, 2016 12:04 pm
by chester
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?).

Re: Delete blank rows in alpha series

Posted: Thu Nov 17, 2016 2:25 pm
by EViews Matt
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

Re: Delete blank rows in alpha series

Posted: Thu Nov 17, 2016 2:38 pm
by chester
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!

Re: Delete blank rows in alpha series

Posted: Thu Nov 17, 2016 3:37 pm
by EViews Jason
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