<?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 #BYVAL within a PROC REPORT Procedure Not Resolving in PDF / HTML or RTF Output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/BYVAL-within-a-PROC-REPORT-Procedure-Not-Resolving-in-PDF-HTML/m-p/711111#M218991</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using the PROC REPORT procedure with the #BYVAL dynamic function. The #BYVAL function works flawlessly in a TITLE statement, be in the output window in SAS or the PDF, RTF or HTML output. However, the #BYVAL function when used within a column header only works within the SAS output window and not the PDF, RFT or HTML output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is same sample code which you should be able to copy and paste into your own SAS session:&lt;/P&gt;
&lt;PRE&gt;data input_data;
    do byvariable1 = 1 to 2 by 1;
        col1 = "XX (XX.X)";
        col2 = "XX (XX.X)";
        if byvariable1=1 then byvariable2 = "Female";
        else if byvariable1=2 then byvariable2 = "Male";

        if byvariable1=1 then do;
            header1 = "Some Text 1";
            header2 = "Some Other Text 1";
        end;
        else if byvariable1=2 then do;
            header1 = "Some Text 2";
            header2 = "Some Other Text 2";
        end;
        output;
    end;
run;


ods listing close;
ods pdf file="%sysfunc(getoption(work))\test.pdf" nogtitle nogfootnote;

    proc report data = input_data split="|" nowd missing;
        column col1 col2;
        by byvariable1 byvariable2 header1 header2;

        define col1 / display "Header 1 #byval3";
        define col2 / display "Header 2 #byval4";
        
        title1 "#byval2";
    run;

ods pdf close;
ods listing;&lt;/PRE&gt;
&lt;P&gt;Notice the COL1 and COL2 variables within the DEFINE statement within the PROC REPORT. I have included #BYVAL3 and #BYVAL4 in the column headers. Now, these do resolve to the correct values within the SAS output window. however, when I open the PDF document they simply say #BYVAL3 and #BYVAL4. Oddly though the #BYVAL2 line within the TITLE statement does appear correctly in both the SAS output window and the PDF output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am running SAS EG guide 7.15 on Windows 10.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jan 2021 14:24:55 GMT</pubDate>
    <dc:creator>craig159753</dc:creator>
    <dc:date>2021-01-13T14:24:55Z</dc:date>
    <item>
      <title>#BYVAL within a PROC REPORT Procedure Not Resolving in PDF / HTML or RTF Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BYVAL-within-a-PROC-REPORT-Procedure-Not-Resolving-in-PDF-HTML/m-p/711111#M218991</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using the PROC REPORT procedure with the #BYVAL dynamic function. The #BYVAL function works flawlessly in a TITLE statement, be in the output window in SAS or the PDF, RTF or HTML output. However, the #BYVAL function when used within a column header only works within the SAS output window and not the PDF, RFT or HTML output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is same sample code which you should be able to copy and paste into your own SAS session:&lt;/P&gt;
&lt;PRE&gt;data input_data;
    do byvariable1 = 1 to 2 by 1;
        col1 = "XX (XX.X)";
        col2 = "XX (XX.X)";
        if byvariable1=1 then byvariable2 = "Female";
        else if byvariable1=2 then byvariable2 = "Male";

        if byvariable1=1 then do;
            header1 = "Some Text 1";
            header2 = "Some Other Text 1";
        end;
        else if byvariable1=2 then do;
            header1 = "Some Text 2";
            header2 = "Some Other Text 2";
        end;
        output;
    end;
run;


ods listing close;
ods pdf file="%sysfunc(getoption(work))\test.pdf" nogtitle nogfootnote;

    proc report data = input_data split="|" nowd missing;
        column col1 col2;
        by byvariable1 byvariable2 header1 header2;

        define col1 / display "Header 1 #byval3";
        define col2 / display "Header 2 #byval4";
        
        title1 "#byval2";
    run;

ods pdf close;
ods listing;&lt;/PRE&gt;
&lt;P&gt;Notice the COL1 and COL2 variables within the DEFINE statement within the PROC REPORT. I have included #BYVAL3 and #BYVAL4 in the column headers. Now, these do resolve to the correct values within the SAS output window. however, when I open the PDF document they simply say #BYVAL3 and #BYVAL4. Oddly though the #BYVAL2 line within the TITLE statement does appear correctly in both the SAS output window and the PDF output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am running SAS EG guide 7.15 on Windows 10.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 14:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BYVAL-within-a-PROC-REPORT-Procedure-Not-Resolving-in-PDF-HTML/m-p/711111#M218991</guid>
      <dc:creator>craig159753</dc:creator>
      <dc:date>2021-01-13T14:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: #BYVAL within a PROC REPORT Procedure Not Resolving in PDF / HTML or RTF Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BYVAL-within-a-PROC-REPORT-Procedure-Not-Resolving-in-PDF-HTML/m-p/711160#M219014</link>
      <description>&lt;P&gt;I could not get the #BYVAL function to work. But I did find a solution using a different method, the ACROSS statement, see the code below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc report data = input_data split="|" nowd missing;
        column blank col1,header1 col2,header2;
        by byvariable1 byvariable2;

        define blank / display "Statistics";

        define header1 / across " ";
        define col1 / display " ";

        define header2 / across " ";
        define col2 / display " ";
        
        title1 "#byval2";
    run;&lt;/PRE&gt;
&lt;P&gt;This code ensures the values in the HEADER1 and HEADER2 variables appear as the column headers for the COL1 and COL2 variables respectively.&lt;BR /&gt;&lt;BR /&gt;If you require multiple columns, e.g. COL3, COL4 to share the same header text, this method also works, however the syntax does change slightly, see the code below.&lt;/P&gt;
&lt;PRE&gt;proc report data = input_data split="|" nowd missing;
        column blank header1,(col1 col2) header2,(col3 col4);
        by byvariable1 byvariable2;

        define blank / display "Statistics";

        define header1 / across " ";
        define col1 / display " ";
        define col2 / display " ";

        define header2 / across " ";
        define col3 / display " ";
        define col4 / display " ";
        
        title1 "#byval2";
    run;
&lt;/PRE&gt;
&lt;P&gt;I am still unsure why the #BYVAL does not work, and will leave this post unresolved until I figure out why.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 15:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BYVAL-within-a-PROC-REPORT-Procedure-Not-Resolving-in-PDF-HTML/m-p/711160#M219014</guid>
      <dc:creator>craig159753</dc:creator>
      <dc:date>2021-01-13T15:32:14Z</dc:date>
    </item>
  </channel>
</rss>

