<?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: ODS PDF Proc report with Conditional Text in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PDF-Proc-report-with-Conditional-Text/m-p/961842#M26834</link>
    <description>&lt;P&gt;Yeah. It is a little complicated ,but still doable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let n=20;   * a page has 20 records ;



DATA AAA;
	SET SASHELP.CARS(obs=400);
RUN;
proc sort data=AAA;
by Make;
run;
data AAA;
 set AAA;
 by Make;
 if first.Make then n=0;
 n+1;
 if first.Make or mod(n,&amp;amp;n.)=1 then PAGE_NO+1;
run;



proc freq data=AAA noprint;
table Make*PAGE_NO/out=PAGE_NO;
run;
data PAGE_NO;
 length Make $ 80;
 set PAGE_NO;
 by Make;
 if not first.Make then Make=catx(' ',Make,'(continued)');
run;






%macro report(PAGE_NO=,Make=);
PROC REPORT DATA=AAA nowd contents='';
where PAGE_NO=&amp;amp;PAGE_NO.;
	COLUMNS ("(*ESC*)S={just=l}For Bucket &amp;amp;Make." Make Model Type Origin DriveTrain MSRP);
	DEFINE Make / 	DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE Model / 		DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE Type / 		DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE Origin / 	DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE DriveTrain / DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE MSRP / 		DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
RUN;
%mend;



ODS PDF FILE= "c:\temp\A.pdf" ;
data _null_;
 set PAGE_NO;
 call execute(catt('%report(PAGE_NO=',PAGE_NO,',Make=',Make,')'));
run;
ODS PDF CLOSE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1741924254812.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105421iBF3F8B016D35963F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1741924254812.png" alt="Ksharp_0-1741924254812.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Mar 2025 03:51:04 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-03-14T03:51:04Z</dc:date>
    <item>
      <title>ODS PDF Proc report with Conditional Text</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PDF-Proc-report-with-Conditional-Text/m-p/961809#M26833</link>
      <description>&lt;P&gt;I want to print a statement at the top of each BYVAL table (or the top of each page) labelling the BYVAL. However, when an ODS PDF page break occurs in &lt;STRONG&gt;the middle of a table&lt;/STRONG&gt;, the label should include the word &lt;STRONG&gt;"(continued)"&lt;/STRONG&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't care if this happens through a line statement, ODS text, conditional label, some span functionality, etc.&amp;nbsp; I don 't care if the proc report uses a BY statement or if I have to create a macro to run each BYVAL individually.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've only tried output ODS PDF, which needs to be the final result.&amp;nbsp; But I guess if ODS PDF is causing the problem, I could use another ODS and save the result to pdf manually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I should be able to do this by evaluating _break_ type or observation number.&amp;nbsp; I feel like I might need a hold value from one compute statement to use in another compute statement, but I can't get it right.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for any advice!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ODS PDF.png" style="width: 892px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105404iF3115AE0D175507B/image-size/large?v=v2&amp;amp;px=999" role="button" title="ODS PDF.png" alt="ODS PDF.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sort data=sashelp.cars out=cars_make;
  by make;
run;
 
ods escapechar='^';
options  nobyline;

Title1 color='black' "^S={font_face='Verdana' font_size=18pt}Title1" ;
Title2 color='black' "^S={font_face='Verdana' font_size=18pt}Title2" ;
Title3 color='black' "^S={font_face='Verdana' font_size=18pt}Title3" ;

ods pdf file ="SGE26.pdf" notoc startpage=no  ;
proc report data=cars_make (firstobs= 1 obs= 500) out=tryout;
   where origin = 'USA';
   by make;
   column make  DISP_make model type origin newobs;
   define make /group noprint;
   define DISP_make /computed;
   define model / order order=internal;
   define type / order order=internal;
   define origin / order order=internal;
   define newobs/display computed;

break after make/;

compute newobs;
	_obs_+1;
	newobs=(_obs_)-1;
endcomp;

compute before _page_ /left;
	length text $100;
	if hold_obs &amp;lt;2 then do;
		text="For Bucket xxx";
		num=100;
	end;
	else do;
		text="For Bucket XXX (continued)";
		num=150;
	end;
	line text $varying. num;
endcomp;


compute before make;
      cnt_make + 1;
      hold_make= make;
	  hold_obs=newobs;
endcomp;

compute DISP_make / character length= 20;
      DISP_make = hold_make;
	
   endcomp;
run;
ods pdf close;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 19:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PDF-Proc-report-with-Conditional-Text/m-p/961809#M26833</guid>
      <dc:creator>kscdenney</dc:creator>
      <dc:date>2025-03-13T19:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: ODS PDF Proc report with Conditional Text</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PDF-Proc-report-with-Conditional-Text/m-p/961842#M26834</link>
      <description>&lt;P&gt;Yeah. It is a little complicated ,but still doable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let n=20;   * a page has 20 records ;



DATA AAA;
	SET SASHELP.CARS(obs=400);
RUN;
proc sort data=AAA;
by Make;
run;
data AAA;
 set AAA;
 by Make;
 if first.Make then n=0;
 n+1;
 if first.Make or mod(n,&amp;amp;n.)=1 then PAGE_NO+1;
run;



proc freq data=AAA noprint;
table Make*PAGE_NO/out=PAGE_NO;
run;
data PAGE_NO;
 length Make $ 80;
 set PAGE_NO;
 by Make;
 if not first.Make then Make=catx(' ',Make,'(continued)');
run;






%macro report(PAGE_NO=,Make=);
PROC REPORT DATA=AAA nowd contents='';
where PAGE_NO=&amp;amp;PAGE_NO.;
	COLUMNS ("(*ESC*)S={just=l}For Bucket &amp;amp;Make." Make Model Type Origin DriveTrain MSRP);
	DEFINE Make / 	DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE Model / 		DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE Type / 		DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE Origin / 	DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE DriveTrain / DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE MSRP / 		DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
RUN;
%mend;



ODS PDF FILE= "c:\temp\A.pdf" ;
data _null_;
 set PAGE_NO;
 call execute(catt('%report(PAGE_NO=',PAGE_NO,',Make=',Make,')'));
run;
ODS PDF CLOSE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1741924254812.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105421iBF3F8B016D35963F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1741924254812.png" alt="Ksharp_0-1741924254812.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 03:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PDF-Proc-report-with-Conditional-Text/m-p/961842#M26834</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-03-14T03:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: ODS PDF Proc report with Conditional Text</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PDF-Proc-report-with-Conditional-Text/m-p/961847#M26835</link>
      <description>&lt;P&gt;If you want compact layout, try this one :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let n=20;   * a page has 20 records ;



DATA AAA;
	SET SASHELP.CARS(obs=400);
RUN;
proc sort data=AAA;
by Make;
run;
data AAA;
 set AAA;
 by Make;
 if first.Make then n=0;
 n+1;
 if first.Make or mod(n,&amp;amp;n.)=1 then PAGE_NO+1;
 drop n;
run;





proc freq data=AAA noprint;
table Make*PAGE_NO/out=PAGE_NO;
run;
data PAGE_NO;
 length Make $ 80;
 set PAGE_NO;
 by Make;
 if not first.Make then Make=catx(' ',Make,'(continued)');

 total+count;
 if total&amp;gt;20 then do;group+1;total=count;end;
run;
data AAA2;
 merge AAA(drop=Make) PAGE_NO(keep=Make PAGE_NO group);
 by PAGE_NO;
run;
proc freq data=PAGE_NO noprint;
table group/out=group;
run;





%macro report(group=);
PROC REPORT DATA=AAA2 nowd contents='';
where group=&amp;amp;group.;
by PAGE_NO;
	COLUMNS  Make  Model Type Origin DriveTrain MSRP;
	DEFINE Make / order	 ;

	DEFINE Model / 		DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE Type / 		DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE Origin / 	DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE DriveTrain / DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	DEFINE MSRP / 		DISPLAY STYLE(COLUMN)={CELLWIDTH=1IN};
	compute before _page_/style={just=l};
     line Make $80.;
	endcomp;
RUN;
%mend;



ODS PDF FILE= "c:\temp\A.pdf" startpage=no;
option nobyline;
data _null_;
 set group end=last;;
 call execute(catt('%report(group=',group,')'));
 if not last then call execute('ods pdf startpage=now;');
run;
ODS PDF CLOSE;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Mar 2025 06:45:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PDF-Proc-report-with-Conditional-Text/m-p/961847#M26835</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-03-14T06:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: ODS PDF Proc report with Conditional Text</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PDF-Proc-report-with-Conditional-Text/m-p/962142#M26836</link>
      <description>&lt;P&gt;Wow!&amp;nbsp; This is quite the "work-around," but it indeed WORKS!&amp;nbsp; Thank you so much!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This second "compacted" method fit my needs better by not automatically page -breaking between the groups.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm pretty new to Proc Report; I never would have thought to create a table to hold the record count, page numbering and the "continued" text.&amp;nbsp; I've added several new concepts to my SAS toolbox by working through this code with my real-life report. Thanks again!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2025 20:28:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PDF-Proc-report-with-Conditional-Text/m-p/962142#M26836</guid>
      <dc:creator>kscdenney</dc:creator>
      <dc:date>2025-03-18T20:28:56Z</dc:date>
    </item>
  </channel>
</rss>

