<?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: Adding an empty row after each by group in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561573#M17197</link>
    <description>&lt;P&gt;Look more carefully at the code you have written and follow the logic of it. Proper indentation will help.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set class;
  by sex age;
  output;
  if last.age then do;
    call missing(of _all_);
    output;
    IF first.ID THEN count=1;
    ELSE count+1;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let's just assume that you meant first.sex instead of first.id&lt;/P&gt;
&lt;P&gt;Notice how the test for first.sex is inside block that only runs at last.age.&amp;nbsp; So that can only be true when first age group in that sex group has only one observation.&lt;/P&gt;
&lt;P&gt;Also notice how the variable COUNT is incremented after the record has already been output.&lt;/P&gt;
&lt;P&gt;It is not clear what you want to count, but the CALL MISSING() is going to blank out the COUNT variable with all of the rest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But my real question is why the heck would you want to add blank observations?&amp;nbsp; Are you just trying to produce a report?&amp;nbsp; PROC PRINT and PROC REPORT can produce reports that insert blank lines after the groups.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 25 May 2019 16:57:04 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-05-25T16:57:04Z</dc:date>
    <item>
      <title>Adding an empty row after each by group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561532#M17190</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;Can someone please tell me how to insert a blank line after each by group. Sorry I could not come up with any code but if you can write the code with sashelp.class table that would be great.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is not possible to do it on sas table please show me how to write that option during exporting to excel.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 02:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561532#M17190</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2019-05-25T02:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Adding an empty row after each by group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561536#M17192</link>
      <description>&lt;P&gt;This might do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.class out=class; by sex age; run;

data want;
set class;
by sex age;
output;
if last.age then do;
    call missing(of _all_);
    output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 May 2019 05:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561536#M17192</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-05-25T05:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Adding an empty row after each by group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561545#M17194</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.iris out=iris; 
   by species; 
run;

data want;
   do until (last.species);
      set iris;
      by species;
      output;
   end;
   call missing(of _all_);
   output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 May 2019 07:08:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561545#M17194</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-25T07:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Adding an empty row after each by group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561568#M17196</link>
      <description>Thanks PGStats. It worked perfect. Would you be able to tell me what the code would be for flagging each by group with chronological number. I added some lines to your code, but I also count the black space.&lt;BR /&gt;&lt;BR /&gt;proc sort data=sashelp.class out=class; by sex age; run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set class;&lt;BR /&gt;by sex age;&lt;BR /&gt;output;&lt;BR /&gt;if last.age then do;&lt;BR /&gt;    call missing(of _all_);&lt;BR /&gt;    output;&lt;BR /&gt;IF first.ID THEN count=1;&lt;BR /&gt;ELSE count+1;&lt;BR /&gt;end;</description>
      <pubDate>Sat, 25 May 2019 16:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561568#M17196</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2019-05-25T16:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding an empty row after each by group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561573#M17197</link>
      <description>&lt;P&gt;Look more carefully at the code you have written and follow the logic of it. Proper indentation will help.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set class;
  by sex age;
  output;
  if last.age then do;
    call missing(of _all_);
    output;
    IF first.ID THEN count=1;
    ELSE count+1;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let's just assume that you meant first.sex instead of first.id&lt;/P&gt;
&lt;P&gt;Notice how the test for first.sex is inside block that only runs at last.age.&amp;nbsp; So that can only be true when first age group in that sex group has only one observation.&lt;/P&gt;
&lt;P&gt;Also notice how the variable COUNT is incremented after the record has already been output.&lt;/P&gt;
&lt;P&gt;It is not clear what you want to count, but the CALL MISSING() is going to blank out the COUNT variable with all of the rest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But my real question is why the heck would you want to add blank observations?&amp;nbsp; Are you just trying to produce a report?&amp;nbsp; PROC PRINT and PROC REPORT can produce reports that insert blank lines after the groups.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 16:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561573#M17197</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-25T16:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Adding an empty row after each by group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561575#M17198</link>
      <description>Hi Tom, I want to insert a blank space so that I can export it to excel from sas table without an extra step of PROC REPORT.</description>
      <pubDate>Sat, 25 May 2019 17:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561575#M17198</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2019-05-25T17:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Adding an empty row after each by group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561582#M17199</link>
      <description>How is writing it to Excel with PROC REPORT or PROC PRINT an extra step? Your step to insert the blank observations is already an extra step.&lt;BR /&gt;</description>
      <pubDate>Sat, 25 May 2019 17:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561582#M17199</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-25T17:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Adding an empty row after each by group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561608#M17200</link>
      <description>Hi Tom, Would you please write the code with PROC REPORT that will export the data to Excel while inserting a blank space after each by group. Thank for your help.</description>
      <pubDate>Sun, 26 May 2019 03:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-an-empty-row-after-each-by-group/m-p/561608#M17200</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2019-05-26T03:55:15Z</dc:date>
    </item>
  </channel>
</rss>

