<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: revoming blanks across columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39590#M8030</link>
    <description>Why 2 loops?&lt;BR /&gt;
[pre]&lt;BR /&gt;
data t;&lt;BR /&gt;
  array varr(3) $2;&lt;BR /&gt;
  input (varr1 varr2 varr3) ($);&lt;BR /&gt;
  FREEPOS=1;                   *position of next free slot;                  &lt;BR /&gt;
  do I=1 to 3;&lt;BR /&gt;
    if varr(I) ne '' then do;  *there is a value to keep;&lt;BR /&gt;
      if I ne FREEPOS then do; *the value must be shifted;&lt;BR /&gt;
        varr(FREEPOS)=varr(I); *shift value;&lt;BR /&gt;
        varr(I)='';            *reset current position since value has moved;&lt;BR /&gt;
      end;&lt;BR /&gt;
      FREEPOS+1;               *update position of next free slot; &lt;BR /&gt;
    end;&lt;BR /&gt;
  end;&lt;BR /&gt;
  put _ALL_;&lt;BR /&gt;
cards;&lt;BR /&gt;
x1 . x3&lt;BR /&gt;
. y2 y3&lt;BR /&gt;
. z2 .&lt;BR /&gt;
run;</description>
    <pubDate>Thu, 04 Jun 2009 03:50:43 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2009-06-04T03:50:43Z</dc:date>
    <item>
      <title>revoming blanks across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39586#M8026</link>
      <description>I want to turn this:&lt;BR /&gt;
&lt;BR /&gt;
var1  var2  var3 ... varX&lt;BR /&gt;
 x1............x3&lt;BR /&gt;
 .......y2.....y3&lt;BR /&gt;
 .......z2........                  &lt;BR /&gt;
&lt;BR /&gt;
into this:&lt;BR /&gt;
&lt;BR /&gt;
var1  var2  var3 ... varX&lt;BR /&gt;
 x1....x3........&lt;BR /&gt;
 y2....y3........&lt;BR /&gt;
 z2................&lt;BR /&gt;
&lt;BR /&gt;
I want to do this for a large number of datasets and X differs for each dataset, so I want to automate the process. This is what I've written so far, where &amp;amp;X is a global macro variable defined in a previous step:&lt;BR /&gt;
&lt;BR /&gt;
data temp03;&lt;BR /&gt;
    array line[&amp;amp;X] $ 60 ;&lt;BR /&gt;
    set temp02;&lt;BR /&gt;
&lt;BR /&gt;
    array nlines {*} line1-line&amp;amp;X;&lt;BR /&gt;
    do i = 1 to (&amp;amp;X);&lt;BR /&gt;
        if nlines(i) = "" and nmiss(of nlines(i+1)-line&amp;amp;X) ne (&amp;amp;X-i) then do;&lt;BR /&gt;
            array nlines2 {*} nlines(i)-line&amp;amp;X;&lt;BR /&gt;
            do j = 1 to (&amp;amp;X-i);&lt;BR /&gt;
                nlines2(j) = nlines2(j+1);&lt;BR /&gt;
                call missing(nlines2(j+1));&lt;BR /&gt;
            end;&lt;BR /&gt;
        end;&lt;BR /&gt;
    end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The issue I'm having results from the term "nlines(i+1)". For example, when i = 1, instead of writing "line2" it writes the actual value of the variable line2. Is there an easy way to refer to the &lt;I&gt;NAME&lt;/I&gt; of an array element rather than its value?&lt;BR /&gt;
&lt;BR /&gt;
Also, I'm sure there are many other ways to remove the blanks, so if you know of any please let me know.&lt;BR /&gt;
&lt;BR /&gt;
Any help is very much appreciated!! Thank you so much!!</description>
      <pubDate>Mon, 01 Jun 2009 21:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39586#M8026</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-01T21:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: revoming blanks across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39587#M8027</link>
      <description>Why not work from this (I would say cleaner) perspective:&lt;BR /&gt;
&lt;BR /&gt;
DO DIM(NLINES) TO 2 BY -1;&lt;BR /&gt;
  * your variable consolidation code goes here. ;&lt;BR /&gt;
END;&lt;BR /&gt;
&lt;BR /&gt;
And do away with the squiggly brackets - a keyboard data-entry challenge - in favor of the much more fluid left- and right-parenthesis keystroke!&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Mon, 01 Jun 2009 22:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39587#M8027</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-01T22:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: revoming blanks across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39588#M8028</link>
      <description>Thanks for the reply. &lt;BR /&gt;
&lt;BR /&gt;
I apologize but I am a bit confused. I agree that this perspective is cleaner, but I'm not sure how it addresses (or if it's meant to address) the issue with nlines(i+1).&lt;BR /&gt;
&lt;BR /&gt;
Also, it's "&lt;B&gt;i = &lt;/B&gt;dim(nlines)", right?&lt;BR /&gt;
&lt;BR /&gt;
Thanks again, I appreciate your help.</description>
      <pubDate>Mon, 01 Jun 2009 22:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39588#M8028</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-01T22:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: revoming blanks across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39589#M8029</link>
      <description>Yes - sorry about that.  You've got it right.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 02 Jun 2009 02:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39589#M8029</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-02T02:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: revoming blanks across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39590#M8030</link>
      <description>Why 2 loops?&lt;BR /&gt;
[pre]&lt;BR /&gt;
data t;&lt;BR /&gt;
  array varr(3) $2;&lt;BR /&gt;
  input (varr1 varr2 varr3) ($);&lt;BR /&gt;
  FREEPOS=1;                   *position of next free slot;                  &lt;BR /&gt;
  do I=1 to 3;&lt;BR /&gt;
    if varr(I) ne '' then do;  *there is a value to keep;&lt;BR /&gt;
      if I ne FREEPOS then do; *the value must be shifted;&lt;BR /&gt;
        varr(FREEPOS)=varr(I); *shift value;&lt;BR /&gt;
        varr(I)='';            *reset current position since value has moved;&lt;BR /&gt;
      end;&lt;BR /&gt;
      FREEPOS+1;               *update position of next free slot; &lt;BR /&gt;
    end;&lt;BR /&gt;
  end;&lt;BR /&gt;
  put _ALL_;&lt;BR /&gt;
cards;&lt;BR /&gt;
x1 . x3&lt;BR /&gt;
. y2 y3&lt;BR /&gt;
. z2 .&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 04 Jun 2009 03:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39590#M8030</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-06-04T03:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: revoming blanks across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39591#M8031</link>
      <description>Many thanks Chris! This works great and is much cleaner than the two loops I had before.</description>
      <pubDate>Sun, 07 Jun 2009 17:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/revoming-blanks-across-columns/m-p/39591#M8031</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-07T17:27:21Z</dc:date>
    </item>
  </channel>
</rss>

