<?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: Conditional footnotes in ods pdf in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936351#M26662</link>
    <description>&lt;P&gt;You don't use the TITLE statement to create footnotes. You use it to create titles. But still, all the information is present in the output, at the cost of doing much less programming, that was the point.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jul 2024 13:22:59 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-07-19T13:22:59Z</dc:date>
    <item>
      <title>Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936330#M26656</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to know if there is any way to program conditional footnotes in ods pdf. I have tried to implement some kind of if/then logic in my code which contains a more or less complex macro. Beforehand, I have defined the footnote text in excel, imported the excel as a sas dataset and created a macro variable with proc sql. The idea was to iterate over my code with a do loop and always print a footnote if the footnote-text-macro-variable is not empty. Now, what is a bit problematic is that as I was recreating an example with the sashelp data sets my code worked just fine. But in my original code it was always just generating the first footnote on every page. With the use of some "put" statements I have figured out that the macro variable is returning the correct value, but the printing is somehow not working.&lt;/P&gt;
&lt;P&gt;LONG STORY SHORT: I am looking for a way to generate footnotes at the end of the page (not at the end of each proc report step) that is &lt;STRONG&gt;different to the one I have used in the code below.&lt;/STRONG&gt; I can not show you my original code, but let me assure you that I have tried a lot of stuff to get the footnotes working. I am guessing the macro structure in my original code is messing with the functioning of the approach below. If you have any idea how to generate some kind of conditional footnotes please let me know.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods escapechar="^";
data cars_with_sort;
    set sashelp.cars (obs=55);
    select (Make);
        when ("Acura") Sort = 1;
        when ("Audi") Sort = 2;
        when ("BMW") Sort = 3;
        when ("Buick") Sort = 4;
        otherwise Sort = .; 
    end;
run;

proc sql noprint;
  select distinct Sort into :Sort separated by " "
  from cars_with_sort;
quit;


%macro Foot;
%do i = 1 %to 4;
%let SortID = %scan(&amp;amp;Sort., &amp;amp;i.);
proc sql noprint;
	 select distinct Make into :FootnoteT separated by " "
	 from cars_with_sort 
	 where Sort = &amp;amp;SortID.;
   quit;
%put Fußnote = &amp;amp;FootnoteT;


 %if %length(&amp;amp;FootnoteT) &amp;gt; 0 %then %do;
       footnote j=l "^S={fontfamily=calibri font_size=10pt} &amp;amp;FootnoteT";
 %end;


data cars;
set cars_with_sort;
where Sort = &amp;amp;SortID.;
run;

ods layout gridded;
proc report data=cars;
	column Make Sort;
	define Make / "Car Model";
	define Sort / noprint;
run;
ods layout end;

%end;
%mend Foot;

options papersize=a4 orientation=portrait nodate leftmargin=1.5cm rightmargin=2.5cm bottommargin=0.5cm topmargin=2cm nonumber;
ods listing close;
ods pdf file = "yourpath\FootnotesTest.pdf";
%Foot;
ods pdf close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2024 11:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936330#M26656</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2024-07-19T11:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936340#M26657</link>
      <description>&lt;P&gt;This works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods escapechar="^";
data cars_with_sort;
    set sashelp.cars (obs=55);
    select (Make);
        when ("Acura") Sort = 1;
        when ("Audi") Sort = 2;
        when ("BMW") Sort = 3;
        when ("Buick") Sort = 4;
        otherwise Sort = .; 
    end;
run;

%macro Foot;
  %local FootnoteT;
  %do i = 1 %to 4;
    %let FootnoteT=;
    proc sql noprint;
       select distinct Make into :FootnoteT 
       from cars_with_sort 
       where Sort = &amp;amp;i.;
       quit;
    
    footnote;
    
    ods layout gridded;
    proc report data=cars_with_sort;
      where Sort = &amp;amp;i.;
      column Make Sort;
      define Make / "Car Model";
      define Sort / noprint;
      %if %length(&amp;amp;FootnoteT) &amp;gt; 0 %then %do;
        footnote j=l "^S={fontfamily=calibri color=red font_size=10pt} &amp;amp;FootnoteT";
      %end;
    run;
    ods layout end;
  
  %end;
%mend Foot;

options papersize=a4 orientation=portrait nodate leftmargin=1.5cm rightmargin=2.5cm bottommargin=0.5cm topmargin=2cm nonumber;
ods listing close;
ods pdf file = "%sysfunc(pathname(WORK))\FootnotesTest.pdf";
%Foot;
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="ChrisNZ_0-1721392477641.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98513i9A9B26ABC7F0AEE2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisNZ_0-1721392477641.png" alt="ChrisNZ_0-1721392477641.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2024 12:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936340#M26657</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-07-19T12:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936343#M26658</link>
      <description>&lt;P&gt;Hey Chris,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you for you reply! Unfortunately, with your approach the footnotes are indeed updated, but not placed where they are supposed to be (at the bottom of the page):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_Manhattan_0-1721393295858.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98514iBE40EA11FC257B89/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_Manhattan_0-1721393295858.png" alt="_Manhattan_0-1721393295858.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Instead, the footnotes are printed below the proc report step which is not needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2024 12:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936343#M26658</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2024-07-19T12:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936347#M26660</link>
      <description>&lt;P&gt;Just a thought — this would be SOOOOO much easier if you wanted to do this using TITLE statement rather than FOOTNOTE. Then you don't need macros at all, you just need a BY statement.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2024 13:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936347#M26660</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-19T13:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936350#M26661</link>
      <description>Hey Paige,&lt;BR /&gt;&lt;BR /&gt;thank your for your reply. Could you elaborate on that thought? In what way would you use a title statement to generate the footnotes? I am not eager to use the footnote statement. It just seemed like the obvious thing to do if one wants to create footnotes^^</description>
      <pubDate>Fri, 19 Jul 2024 13:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936350#M26661</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2024-07-19T13:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936351#M26662</link>
      <description>&lt;P&gt;You don't use the TITLE statement to create footnotes. You use it to create titles. But still, all the information is present in the output, at the cost of doing much less programming, that was the point.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2024 13:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936351#M26662</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-19T13:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936352#M26663</link>
      <description>Alright, thanks I appreciate it! May I ask if you could modify the code to show how to simplify it? Maybe I could integrate your approach to update my original code.</description>
      <pubDate>Fri, 19 Jul 2024 13:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936352#M26663</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2024-07-19T13:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936353#M26664</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options nobyline;
title 'All Models of #byval1';
proc report data=sashelp.cars(where=(make in ("Audi",'Acura','BMW','Buick')));
    by make;
    columns model msrp invoice mpg_city;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jul 2024 13:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936353#M26664</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-19T13:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936356#M26665</link>
      <description>I see what you are saying. But sadly it is not working for my initial problem as I need the footnotes. Thank you anyway!</description>
      <pubDate>Fri, 19 Jul 2024 13:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936356#M26665</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2024-07-19T13:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936418#M26666</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; This worked for me:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1721416616646.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98547i712D078DDBF11DD6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1721416616646.png" alt="Cynthia_sas_0-1721416616646.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2024 19:17:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936418#M26666</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-07-19T19:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936419#M26667</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I looked in the documentation for footnotes, and didn't anywhere that indicated #byval1 (and similar) could be used. But I didn't actually try it.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2024 19:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936419#M26667</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-19T19:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936461#M26668</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, I know. I thought that too when I first looked at it and then some faint memory of a past program led me to try it. &lt;BR /&gt;Cynthia</description>
      <pubDate>Fri, 19 Jul 2024 21:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936461#M26668</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-07-19T21:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936464#M26669</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt; I will request documentation be changed.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2024 21:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936464#M26669</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-19T21:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936480#M26670</link>
      <description>&lt;P&gt;It is mentioned in a section of the docs on ODS GRAPHICS:&amp;nbsp;&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n1ukd9sqgqiwwhn1mrx4c1rbse1j.htm#p0uv7aycufekfdn1jyaf35cvxeuj" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n1ukd9sqgqiwwhn1mrx4c1rbse1j.htm#p0uv7aycufekfdn1jyaf35cvxeuj&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I agree, it would be good to include this in the documentation for the FOOTNOTE statement, as it is in the docs for the TITLE statement.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2024 02:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936480#M26670</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-07-20T02:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936504#M26672</link>
      <description>&lt;P&gt;Note that #BYVAL() works in footnote for PDF output.&amp;nbsp; But not that well in HTML output. I assume because HTML output does not really have any type of page concept.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.class out=class; by sex; run;
options nobyline;
proc print data=class;
  by sex;
  pageby sex;
  title1 "From: #byval(sex) ";
  footnote1 "To: #byval(sex) ";
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Works for PDF results but the HTML results look like this:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2024-07-20 at 2.10.46 PM.png" style="width: 242px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98565iED3AB208F49A2A6C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2024-07-20 at 2.10.46 PM.png" alt="Screen Shot 2024-07-20 at 2.10.46 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2024 18:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936504#M26672</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-20T18:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936505#M26673</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;: Exactly right! Remember how HTML was supposed to lead to the paperless office? There are not any page breaks on the HTML page to know where a footnote goes. And if someone prints an HTML page, the page breaks are determined by the browser and the printer, after SAS has finished creating the output, so the footnotes from SAS would not be surfaced there.&lt;BR /&gt;Cynthia</description>
      <pubDate>Sat, 20 Jul 2024 18:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936505#M26673</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-07-20T18:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936514#M26674</link>
      <description>To be fair, MS Word also changes the page layout when you change printer. Only PDF files provide a reliable formatting.</description>
      <pubDate>Sun, 21 Jul 2024 08:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936514#M26674</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-07-21T08:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional footnotes in ods pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936557#M26675</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;thank your for your input. Your idea works fine in the code I have posted here, but again not in my "original" one. I have tried to recreate an example to visualize my problem. Even though it is rubbish data the problem should be understandable. Short description of the problems:&lt;/P&gt;
&lt;P&gt;1) The Footnote is printed below the according proc report step - not at the end of the page.&lt;/P&gt;
&lt;P&gt;2) There is a footnote printed at page 2 that states "footnote: #byval1" which seems to be similar to the html output issue&lt;/P&gt;
&lt;P&gt;The screenshot below the code shows the problem aswell.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib=work nolist; delete sample_data input_data mean: VariableInfo freq: ;run ;quit;

%let yourpath=\FootnoteTest.pdf;

ods listing;
/*** Example Data ***/
data work.sample_data;
  input EZGH25A EZGH25B EZGH25C EZGH25D EZGH25E AGHK50A AGHK50B AGHK50C BGKO28A BGKO28B;
  datalines;
  10 20 30 40 50  1 2 3 2 3
  15 25 35 45 55  1 3 4 3 2
  5  10 15 20 25  2 2 3 3 2
  20 30 40 50 60  4 3 2 1 1
  25 35 45 55 65  1 1 1 2 3
  ;
run;

data work.input_data;
   length FT $20 Info1 $1000 Info2 $1000;
   input FT $ Info1 $ Info2 $ Sort;
   infile datalines delimiter=",";
   datalines;
   FootnoteONE, Variable,Answer your Item Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,1
   FootnoteTWO, AGHK50A Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,Item A Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,1
   FootnoteTHREE, AGHK50B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,1
   FootnoteFOUR, AGHK50C,Item C Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,1
   FootnoteFIVE, Variable,Answer your Item Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,2
   FootnoteSIX, BGKO28A,Item A Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,2
   FootnoteSEVEN, BGKO28B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,2
   FootnoteEIGHT, Variable,Answer your Item Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
   FootnoteNINE, EZGH25A,Item A Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
   FootnoteTEN, EZGH25B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
   FootnoteELEVEN, EZGH25C,Item C Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
   FootnoteTWELVE, EZGH25D,Item D Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
   FootnoteTHIRTEEN, EZGH25E,Item E Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
;

/* Using proc sql for a Sorting Variable which is used to iterate trough the do-loop */
proc sql noprint;
   select distinct Sort into :Sort separated by " "
   from work.input_data;
quit;

%put &amp;amp;Sort; 

%let varlistE = EZGH25A EZGH25B EZGH25C EZGH25D EZGH25E;
%let varlistA = AGHK50A AGHK50B AGHK50C BGKO28A BGKO28B;

/* Mean Calculation */
proc means data=work.sample_data noprint;
  var &amp;amp;varlistE;
  output out=work.mean_ezgh;
run;

%macro meandata;
   %do i = 1 %to %sysfunc(countw(&amp;amp;varlistE));
   %let vmean = %scan(&amp;amp;varlistE, &amp;amp;i);
   
   data work.mean&amp;amp;vmean;
      set work.mean_ezgh (keep=&amp;amp;vmean);
   run;
   
   %end;
%mend meandata;
%meandata;

/* Freq calculation */
%macro freqdata;
   %do i = 1 %to %sysfunc(countw(&amp;amp;varlistA));
   %let vfreq = %scan(&amp;amp;varlista, &amp;amp;i);
   
   proc freq data=work.sample_data;
      tables &amp;amp;vfreq/ out=work.freq&amp;amp;vfreq;
   run;
   
   %end;
%mend freqdata;

%freqdata;


/*** Macro Loop ***/

%macro Testloop;
  %do i = 1 %to %sysfunc(countw(&amp;amp;Sort.));
    %let SortID = %scan(&amp;amp;sort, &amp;amp;i);
    %let VariableA = %scan(&amp;amp;varlistA, &amp;amp;i);
    %let VariableE = %scan(&amp;amp;varlistE, &amp;amp;i);
    



/* Compute Variable Information for each Variable */
    data VariableInfo;
      set work.input_data;
      where Sort = &amp;amp;SortID.;
      drop Sort;
    run;
    
   %local Info1Items;
   %let Info1Items=;
   PROC SQL noprint;
      SELECT distinct Info1 INTO :Info1Items SEPARATED BY " "/*new*/
      FROM work.input_data
      WHERE Sort = &amp;amp;SortID.
      AND Info1 not in ('' 'Variable');
   QUIT;


   ods pdf startpage=no; 
   ods layout gridded columns=1; 
   ods region;
/* Report Variable Information for each Variable */
	footnote "Footnote: #byval1";
    proc report data=VariableInfo noheader;
      by FT;	
      column Info1 Info2;
    run;
    
ods layout end;
    
   %MACRO PrinItemStats(Item=,colPosition=);
   ods layout gridded columns=1;
      ods region;
      %if %sysfunc(exist(freq&amp;amp;Item.)) %then %do; 
         /* Print Frequency Table */
         
         proc report data=freq&amp;amp;Item.;
            column &amp;amp;Item. COUNT PERCENT;
            define &amp;amp;Item / display "&amp;amp;Item.";
            define COUNT / display "Absolut";
            define PERCENT / display "Percent";
         run;
      %end;

      %if %sysfunc(exist(mean&amp;amp;Item.)) %then %do; 
         /* Print Mean Table */
         proc report data=mean&amp;amp;Item.;
            column &amp;amp;Item.; 
         run;
      %end;
   ods layout end;
   %MEND PrinItemStats;


   %local j currItem;
   %LET j=1;
   %LET currItem=%SCAN(&amp;amp;Info1Items.,&amp;amp;j.,%STR( ));


   %DO %WHILE(%LENGTH(&amp;amp;currItem.)&amp;gt;0);


      %PrinItemStats(Item=&amp;amp;currItem.);

      %LET j=%EVAL(&amp;amp;j.+1);
      %LET currItem=%SCAN(&amp;amp;Info1Items.,&amp;amp;j.,%STR( ));
   %END;


  %end;


%mend Testloop;

ods _all_ close;
options  papersize=a4 orientation=portrait leftmargin=1.5cm rightmargin=1.5cm topmargin=1.5cm bottommargin=1.5cm nodate nonumber nobyline nobysorted;
ods pdf file="&amp;amp;yourpath.";
%Testloop;
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="_Manhattan_0-1721640255615.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98569i32B92A4DDEC60509/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_Manhattan_0-1721640255615.png" alt="_Manhattan_0-1721640255615.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2024 09:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-footnotes-in-ods-pdf/m-p/936557#M26675</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2024-07-22T09:24:47Z</dc:date>
    </item>
  </channel>
</rss>

