<?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 Keep one empty line in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Keep-one-empty-line/m-p/893570#M43656</link>
    <description>&lt;P&gt;Hi community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to keep one empty line if there are multiple contiguous lines? I want to maintain the same&amp;nbsp;row order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried distinct, but only one empty line is returned and the original row order is lost.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
CREATE TABLE  HAVE
(var1 char(10),
 var2 char(10));

INSERT INTO HAVE
VALUES('A', 'B')
VALUES('', '')
VALUES('', '')
VALUES('', '')
VALUES('C', 'D')
VALUES('', '')
VALUES('', '')
VALUES('E', 'F')
VALUES('', '')
VALUES('', '')
VALUES('', '')
VALUES('', '')
VALUES('G', 'H')
;
QUIT;

proc sql;
CREATE TABLE  WANT
(var1 char(10),
 var2 char(10));

INSERT INTO WANT
VALUES('A', 'B')
VALUES('', '')
VALUES('C', 'D')
VALUES('', '')
VALUES('E', 'F')
VALUES('', '')
VALUES('G', 'H');
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 11 Sep 2023 15:07:43 GMT</pubDate>
    <dc:creator>MM88</dc:creator>
    <dc:date>2023-09-11T15:07:43Z</dc:date>
    <item>
      <title>Keep one empty line</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Keep-one-empty-line/m-p/893570#M43656</link>
      <description>&lt;P&gt;Hi community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to keep one empty line if there are multiple contiguous lines? I want to maintain the same&amp;nbsp;row order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried distinct, but only one empty line is returned and the original row order is lost.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
CREATE TABLE  HAVE
(var1 char(10),
 var2 char(10));

INSERT INTO HAVE
VALUES('A', 'B')
VALUES('', '')
VALUES('', '')
VALUES('', '')
VALUES('C', 'D')
VALUES('', '')
VALUES('', '')
VALUES('E', 'F')
VALUES('', '')
VALUES('', '')
VALUES('', '')
VALUES('', '')
VALUES('G', 'H')
;
QUIT;

proc sql;
CREATE TABLE  WANT
(var1 char(10),
 var2 char(10));

INSERT INTO WANT
VALUES('A', 'B')
VALUES('', '')
VALUES('C', 'D')
VALUES('', '')
VALUES('E', 'F')
VALUES('', '')
VALUES('G', 'H');
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 15:07:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Keep-one-empty-line/m-p/893570#M43656</guid>
      <dc:creator>MM88</dc:creator>
      <dc:date>2023-09-11T15:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Keep one empty line</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Keep-one-empty-line/m-p/893597#M43657</link>
      <description>&lt;P&gt;Sequential processing is not an SQL strong point. If there aren't other variable values involved SQL is not likely to get anything resembling what you want. A SAS data set could but why do you want any "empty line" values at all?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   retain bc;
   if not missing(var1) then bc=0;
   else bc+1;
   if bc&amp;lt;2;
   drop bc;
run;&lt;/PRE&gt;
&lt;P&gt;BC retains a variable for counting blank lines. That means the value is kept across iterations of the data step. Each time var1 is encountered with a none missing value it is reset to 0. If var1 is missing then the count is incremented. The If BC&amp;lt;2 means only the BC=0 or 1 are written to the output set. The drop means the BC variable isn't written to the set.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 16:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Keep-one-empty-line/m-p/893597#M43657</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-11T16:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Keep one empty line</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Keep-one-empty-line/m-p/893606#M43658</link>
      <description>&lt;P&gt;One line of what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use BY group processing.&amp;nbsp; Just use the NOTSORTED option to let SAS know that you do not expect the observations to actually be sorted.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by var1 var2 notsorted;
  if 2=cmiss(of var1 var2) and not first.var2 then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Sep 2023 17:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Keep-one-empty-line/m-p/893606#M43658</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-09-11T17:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Keep one empty line</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Keep-one-empty-line/m-p/893743#M43663</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, your solution also works. Regards.</description>
      <pubDate>Tue, 12 Sep 2023 11:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Keep-one-empty-line/m-p/893743#M43663</guid>
      <dc:creator>MM88</dc:creator>
      <dc:date>2023-09-12T11:31:48Z</dc:date>
    </item>
  </channel>
</rss>

