<?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: footnote behavior in proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/footnote-behavior-in-proc-sql/m-p/510894#M137491</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34629"&gt;@jteres&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm a little confused about how FOOTNOTES behave in PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had sort of assumed that FOOTNOTES behaved similar to TITLES.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34629"&gt;@jteres&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you're right, but this means that they have to be specified &lt;EM&gt;before&lt;/EM&gt; the SELECT statement that produces the output. In your case this is unfortunate because the desired value of &amp;amp;SQLOBS is available only &lt;EM&gt;after&lt;/EM&gt; the SELECT statement has executed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the NUMBER option of the PROC SQL statement to obtain row numbers in the output, in particular the number of the last row.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql number;
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Your FOOTNOTE2 statement will affect output that is created after that statement, e.g., if you run your code twice.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Nov 2018 20:53:38 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-11-06T20:53:38Z</dc:date>
    <item>
      <title>footnote behavior in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/footnote-behavior-in-proc-sql/m-p/510884#M137490</link>
      <description>&lt;P&gt;I'm a little confused about how FOOTNOTES behave in PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had sort of assumed that FOOTNOTES behaved similar to TITLES. They seem to have similar behavior in terms of persistence, but I can't really make sense of how this code behaves:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
     title "query 1: unique values of sex" ;
     select    distinct
               Sex
     from      sashelp.class ;
     footnote       "query 1: &amp;amp;SQLObs rows" ;
     %put NOTE: There were &amp;amp;SQLObs rows read from sashelp.class. ;

     title "query 2: unique combinations of sex and age" ;
     select    distinct
               Sex,
               Age
     from      sashelp.class ;
     %put NOTE: There were &amp;amp;SQLObs rows read from sashelp.class. ;
     footnote2      "query 2: &amp;amp;SQLObs rows" ;
quit ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When I run it, i get the following output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;TABLE class="systitleandfootercontainer" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;query 1: unique values of sex&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure SQL: Query Results" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;Sex&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;F&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;M&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;
&lt;TABLE class="systitleandfootercontainer" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;query 2: unique combinations of sex and age&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure SQL: Query Results" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;Sex&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Age&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;F&lt;/TD&gt;
&lt;TD class="r data"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;F&lt;/TD&gt;
&lt;TD class="r data"&gt;12&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;F&lt;/TD&gt;
&lt;TD class="r data"&gt;13&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;F&lt;/TD&gt;
&lt;TD class="r data"&gt;14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;F&lt;/TD&gt;
&lt;TD class="r data"&gt;15&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;M&lt;/TD&gt;
&lt;TD class="r data"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;M&lt;/TD&gt;
&lt;TD class="r data"&gt;12&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;M&lt;/TD&gt;
&lt;TD class="r data"&gt;13&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;M&lt;/TD&gt;
&lt;TD class="r data"&gt;14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;M&lt;/TD&gt;
&lt;TD class="r data"&gt;15&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;M&lt;/TD&gt;
&lt;TD class="r data"&gt;16&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;
&lt;TABLE class="systitleandfootercontainer" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemfooter"&gt;query 1: 2 rows&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the footnote appears only at the end of the PROC (which is consistent with the description of the FOOTNOTE statement in the documentation) but the footnote2 doesn't appear.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I looked around but couldn't see anything that explicitly discusses how footnotes behave in PROC SQL when you are executing multiple queries in a single PROC.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess my question is, where should I specify footnotes, and how can I expect them to behave?&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Nov 2018 20:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/footnote-behavior-in-proc-sql/m-p/510884#M137490</guid>
      <dc:creator>jteres</dc:creator>
      <dc:date>2018-11-06T20:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: footnote behavior in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/footnote-behavior-in-proc-sql/m-p/510894#M137491</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34629"&gt;@jteres&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm a little confused about how FOOTNOTES behave in PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had sort of assumed that FOOTNOTES behaved similar to TITLES.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34629"&gt;@jteres&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you're right, but this means that they have to be specified &lt;EM&gt;before&lt;/EM&gt; the SELECT statement that produces the output. In your case this is unfortunate because the desired value of &amp;amp;SQLOBS is available only &lt;EM&gt;after&lt;/EM&gt; the SELECT statement has executed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the NUMBER option of the PROC SQL statement to obtain row numbers in the output, in particular the number of the last row.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql number;
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Your FOOTNOTE2 statement will affect output that is created after that statement, e.g., if you run your code twice.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 20:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/footnote-behavior-in-proc-sql/m-p/510894#M137491</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-06T20:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: footnote behavior in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/footnote-behavior-in-proc-sql/m-p/510896#M137492</link>
      <description>&lt;P&gt;As you pointed out, he documentation is clear:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;FOOTNOTE Statement:&amp;nbsp;&lt;SPAN class="shortDesc"&gt;Writes up to 10 lines of text at the bottom of the procedure or DATA step output.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;SPAN class="shortDesc"&gt;where should I specify footnotes, and how can I expect them to behave?&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="shortDesc"&gt;The footnote is somewhat part of the query and must be&amp;nbsp;known&amp;nbsp;when the query runs.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="shortDesc"&gt;Since there is no query after your &lt;FONT face="courier new,courier"&gt;footnote2&lt;/FONT&gt;, it is ignored.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="shortDesc"&gt;[Edited: you already had a reply from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="shortDesc"&gt;Another way to display the observation count is to add something like this at the end of the procedure:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="shortDesc"&gt;&lt;FONT face="courier new,courier"&gt; title;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt; select "&amp;amp;SQLObs" "Nb obs" from sashelp.class(obs=1);&lt;/FONT&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="shortDesc"&gt;&lt;FONT face="courier new,courier"&gt;ods text=Nb obs: &amp;amp;sqlobs";&lt;BR /&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="shortDesc"&gt;]&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 21:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/footnote-behavior-in-proc-sql/m-p/510896#M137492</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-11-06T21:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: footnote behavior in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/footnote-behavior-in-proc-sql/m-p/510952#M137505</link>
      <description>&lt;P&gt;As has been pointed out, the footnote text has to be established before the select statement that invokes the footnote, but that is too soon to have &amp;amp;sqlobs resolved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One solution is to run each query as&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;a create table dummy as ...,&lt;/LI&gt;
&lt;LI&gt;then the title and footnotes,&lt;/LI&gt;
&lt;LI&gt;then a select * from dummy:&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;footnote;
title;
dm 'clear out';
proc sql ;
   create table dummy as 
     select    distinct
               Sex
     from      sashelp.class ;
     title "query 1: unique values of sex" ;
     footnote       "query 1: &amp;amp;SQLObs rows" ;
   select * from dummy;
     %put NOTE: There were &amp;amp;SQLObs rows read from sashelp.class. ;

   create table dummy as
     select    distinct
               Sex,
               Age
     from      sashelp.class ;
     title "query 2: unique combinations of sex and age" ;
     footnote      "query 2: &amp;amp;SQLObs rows" ;
   select * from dummy;
     %put NOTE: There were &amp;amp;SQLObs rows read from sashelp.class. ;
quit ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually the TITLE statements could precede the create table dummy expressions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I suspect you don't really want FOOTNOTE2 for the second table, so I changed it to FOOTNOTE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, this means an extra pass through the data, but if it is for purposes of printing, it's probably not big enough to be costly.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 05:40:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/footnote-behavior-in-proc-sql/m-p/510952#M137505</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-11-07T05:40:27Z</dc:date>
    </item>
  </channel>
</rss>

