<?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: Insert lines after Group in PROC REPORT in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Insert-lines-after-Group-in-PROC-REPORT/m-p/414562#M67509</link>
    <description>&lt;P&gt;The second bit using macro code doesn't show anything because you are using macro %if with data set values. The macro facility generates code and all the % statement elements are compiled and resolved before the procedure starts to execute. The macro facility does not look at the values of the data set variables only of macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This seems to do what I think you are asking for:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $val1_ 
'A'="Summary1 = &amp;amp;VALA1"
'B'="Summary1 = &amp;amp;VALB1"
;
value $val2_ 
'A'="Summary2 = &amp;amp;VALA2"
'B'="Summary2 = &amp;amp;VALB2"
;
run;

proc report data=test spanrows nowd out=outrpt;
 columns Group col1 col2;
 define group / group;
 define col1 / display;
 define col2 /display;
 compute after group;
    line Group $val1_.;
    line Group $val2_.;
 endcomp;
 compute after;
 line "Footnote text";
 endcomp;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you cannot define custom formats that end in a digit, hence the _ I used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Nov 2017 22:47:45 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-11-17T22:47:45Z</dc:date>
    <item>
      <title>Insert lines after Group in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-lines-after-Group-in-PROC-REPORT/m-p/414514#M67508</link>
      <description>&lt;P&gt;Hello SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a report that prints additional lines with extra information after each group value. The extra information is currently stored as macro variables. I can set this layout up, however, I am having a hard time telling SAS what pieces of information to put when.&amp;nbsp;In the sample report below, I want the first&amp;nbsp;break to only read "Summary1 = A1" and "Summary2 = A2" and the second break to read "Summary1 = B1" and "Summary2 = B2".&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 129px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16714i599361FDCF25AE47/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is sample code with two options I've tried, neither are working how I envision they should:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let VALA1 = A1;&lt;BR /&gt;%let VALA2 = A2;&lt;BR /&gt;%let VALB1 = B1;&lt;BR /&gt;%let VALB2 = B2;&lt;BR /&gt;&lt;BR /&gt;data test;&lt;BR /&gt;input group $ col1 col2;&lt;BR /&gt;datalines;&lt;BR /&gt;A 1 1&lt;BR /&gt;A 2 2&lt;BR /&gt;A 3 3&lt;BR /&gt;B 4 4&lt;BR /&gt;B 5 5&lt;BR /&gt;B 6 6&lt;BR /&gt;;run;&lt;BR /&gt;&lt;BR /&gt;proc report data=test spanrows nowd out=outrpt;&lt;BR /&gt; columns Group col1 col2;&lt;BR /&gt; define group / group;&lt;BR /&gt; define col1 / display;&lt;BR /&gt; define col2 /display;&lt;BR /&gt; compute after group;&lt;BR /&gt; if Group = "A" then do;&lt;BR /&gt; line "Summary1 = &amp;amp;VALA1";&lt;BR /&gt; line "Summary2 = &amp;amp;VALA2";&lt;BR /&gt; end;&lt;BR /&gt; if Group = "B" then do;&lt;BR /&gt; line "Summary1 = &amp;amp;VALB1";&lt;BR /&gt; line "Summary2 = &amp;amp;VALB2";&lt;BR /&gt; end;&lt;BR /&gt; endcomp;&lt;BR /&gt; compute after;&lt;BR /&gt; line "Footnote text";&lt;BR /&gt; endcomp;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%Macro Test;&lt;BR /&gt;proc report data=test spanrows nowd;&lt;BR /&gt; columns Group col1 col2;&lt;BR /&gt; define group / group;&lt;BR /&gt; define col1 / display;&lt;BR /&gt; define col2 /display;&lt;BR /&gt; compute after group;&lt;BR /&gt; %if Group = "A" %then %do;&lt;BR /&gt; line "Summary1 = &amp;amp;VALA1";&lt;BR /&gt; line "Summary2 = &amp;amp;VALA2";&lt;BR /&gt; %end;&lt;BR /&gt; %if Group = "B" %then %do;&lt;BR /&gt; line "Summary1 = &amp;amp;VALB1";&lt;BR /&gt; line "Summary2 = &amp;amp;VALB2";&lt;BR /&gt; %end;&lt;BR /&gt; endcomp;&lt;BR /&gt; compute after;&lt;BR /&gt; line "Footnote text";&lt;BR /&gt; endcomp;&lt;BR /&gt;run;&lt;BR /&gt;%Mend Test;&lt;BR /&gt;%Test;&lt;/PRE&gt;&lt;P&gt;The first PROC REPORT prints both lines after each group value as if it's&amp;nbsp;ignoring the IF/THEN blocks. The second PROC REPORT doesn't print any lines. Does anyone have ideas for solutions? Ideally I would keep the extra information stored as macro variables, but if it works to add in as separate columns,&amp;nbsp;I can do that as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 19:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-lines-after-Group-in-PROC-REPORT/m-p/414514#M67508</guid>
      <dc:creator>bstarr</dc:creator>
      <dc:date>2017-11-17T19:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: Insert lines after Group in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-lines-after-Group-in-PROC-REPORT/m-p/414562#M67509</link>
      <description>&lt;P&gt;The second bit using macro code doesn't show anything because you are using macro %if with data set values. The macro facility generates code and all the % statement elements are compiled and resolved before the procedure starts to execute. The macro facility does not look at the values of the data set variables only of macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This seems to do what I think you are asking for:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $val1_ 
'A'="Summary1 = &amp;amp;VALA1"
'B'="Summary1 = &amp;amp;VALB1"
;
value $val2_ 
'A'="Summary2 = &amp;amp;VALA2"
'B'="Summary2 = &amp;amp;VALB2"
;
run;

proc report data=test spanrows nowd out=outrpt;
 columns Group col1 col2;
 define group / group;
 define col1 / display;
 define col2 /display;
 compute after group;
    line Group $val1_.;
    line Group $val2_.;
 endcomp;
 compute after;
 line "Footnote text";
 endcomp;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you cannot define custom formats that end in a digit, hence the _ I used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 22:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-lines-after-Group-in-PROC-REPORT/m-p/414562#M67509</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-17T22:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Insert lines after Group in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-lines-after-Group-in-PROC-REPORT/m-p/414570#M67511</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;The issue that the OP encountered was due to the fact that with PROC REPORT, the LINE statement output is ALWAYS written. You cannot execute a LINE statement conditionally. In many ways, the LINE statement has behavior in common with the PUT statement. But, where a PUT can be executed based on a condition, the LINE statement cannot be executed based on a condition. The LINE statement is ALWAYS written and is ALWAYS written after all the other statements in the COMPUTE block have executed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You CAN however, make a temporary variable and control the text that you write using conditions, like this:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;if xx=1 then tmpvar='This is for 1';&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;else if xx=2 then tmpvar='This is for 2';&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;line tmpvar $100.;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; Or you can make separate columns and add extra breaking variables, as shown on page 28 of this paper &lt;A href="https://www.sas.com/content/dam/SAS/support/en/technical-papers/SAS0431-2017.pdf" target="_blank"&gt;https://www.sas.com/content/dam/SAS/support/en/technical-papers/SAS0431-2017.pdf&lt;/A&gt; see Output 23 for the example.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; I assume you want something like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diff_line.png" style="width: 243px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16718iE297527FE2DCF223/image-size/large?v=v2&amp;amp;px=999" role="button" title="diff_line.png" alt="diff_line.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; Here's some sample code that created the above screen shot.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sort data=sashelp.class out=class;
  where age le 13;
  by age;
run;
  
%let grp1=Group 1;
%let grp2=Group 2;
%let grp3=Group 3;


proc report data=class
  style(summary)=Header
  style(lines)=Header{just=l};
  column age sex ('Average' height weight);
  define age / group;
  define sex / group;
  define height / mean f=6.2;
  define weight / mean f=6.2;
  break after age / summarize;
  compute after age;
    length want_this1 $100 want_this2 $1;
	want_this2=' ';
	if age = 11 then do;
	   want_this1=catx(' ',"&amp;amp;grp1","for age",age);
	   lg2=1;
    end;
	else if age = 12 then do;
	   want_this1=catx(' ',"&amp;amp;grp2","for age",age);
	   lg2=1;
    end;
	else if age = 13 then do;
	   want_this1=catx(' ',"&amp;amp;grp3","for age",age);
	   lg2=0;
    end;
	line want_this1 $100.;
	line want_this2 $varying. lg2;
  endcomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;In the above example, &lt;STRONG&gt;want_this1&lt;/STRONG&gt; and &lt;STRONG&gt;want_this2&lt;/STRONG&gt; are the temporary variables. The string to print is assigned conditionally to &lt;STRONG&gt;want_this1&lt;/STRONG&gt;. Then,&lt;STRONG&gt; want_this2&lt;/STRONG&gt; is just a blank. Notice how there is a blank line under Group 1 and Group 2, but not under Group 3. &lt;STRONG&gt;Want_this2&lt;/STRONG&gt; was assigned a value of blank, but the printing of the line was controlled by using a length of either 1 or 0. For the LINE statement, if you use $VARYING. format with a length of 0, then PROC REPORT suppresses writing the LINE.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Sat, 18 Nov 2017 02:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-lines-after-Group-in-PROC-REPORT/m-p/414570#M67511</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-11-18T02:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Insert lines after Group in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Insert-lines-after-Group-in-PROC-REPORT/m-p/414853#M67534</link>
      <description>&lt;P&gt;Cynthia, thank you for explaining the causes of why I was getting "unexpected" behavior and posting a solution! This is exactly what I was looking for and works when I extend the logic to my production code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Brian&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 14:50:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Insert-lines-after-Group-in-PROC-REPORT/m-p/414853#M67534</guid>
      <dc:creator>bstarr</dc:creator>
      <dc:date>2017-11-20T14:50:20Z</dc:date>
    </item>
  </channel>
</rss>

