<?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: Need an output with two separate proc report on each tab in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-an-output-with-two-separate-proc-report-on-each-tab/m-p/897266#M354545</link>
    <description>&lt;P&gt;You aren't doing anything "wrong".&amp;nbsp; If you have two procedures that have to run in parallel you have to control things tighter. #Byval is the value &lt;STRONG&gt;in one procedure call.&lt;/STRONG&gt; So if you want to call the report so that "First" appears from two different procedures you have to force that behavior.&amp;nbsp; Your example data is likely way simpler than reality otherwise I would ask what is wrong with showing columns A and B in the same table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would turn on/off sheet starts to "reset" the output to a new sheet, then use "none" to get related different procedure calls onto the same sheet.&amp;nbsp; Select the specific data with WHERE statements and manually set the names.&lt;/P&gt;
&lt;PRE&gt;ods excel file="C:\TEST_EXAMPLE.xlsx"
options(sheet_interval='none' sheet_name="First") ;

proc report data=test;
Where ORDER='First';
column A;

run;

proc report data=test ;
Where ORDER='First';
column B;
run;

ods excel options(sheet_interval='proc');
ods excel options(sheet_interval='none' Sheet_name='Second');

proc report data=test;
Where ORDER='Second';
column A;

run;

proc report data=test ;
Where ORDER='Second';
column B;
run;

ods excel options(sheet_interval='proc');
ods excel options(sheet_interval='none' Sheet_name='Third');

proc report data=test;
Where ORDER='Third';
column A;

run;

proc report data=test ;
Where ORDER='Third';
column B;
run;


ods excel close;

&lt;/PRE&gt;
&lt;P&gt;Possibly you might be able to restructure your data and make a different procedure call but would have to see very complete example of the complete data and reports to tell if that might be possible.&lt;/P&gt;
&lt;P&gt;People have used the SAS macro language to do such group processing or similar can be accomplished by using a data set with the items that change, such are the values of Order and using a data step with that data set and CALL EXECUTE statements to write the blocks of values.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Oct 2023 20:16:42 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-10-04T20:16:42Z</dc:date>
    <item>
      <title>Need an output with two separate proc report on each tab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-an-output-with-two-separate-proc-report-on-each-tab/m-p/897258#M354541</link>
      <description>&lt;P&gt;ORDER&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/P&gt;
&lt;P&gt;First&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp;55&lt;/P&gt;
&lt;P&gt;Second&amp;nbsp; &amp;nbsp; &amp;nbsp; 12&amp;nbsp; &amp;nbsp; &amp;nbsp; 34&lt;/P&gt;
&lt;P&gt;Third&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 14&amp;nbsp; &amp;nbsp; &amp;nbsp; 42&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Trying to get an Excel output with three tabs: First, Second and Third.&amp;nbsp; I need two proc reports on each tab.&amp;nbsp; &amp;nbsp;First report should display variable A and second report should display variable B.&amp;nbsp; &amp;nbsp;I get six tabs: First, Second, Third, First2, Second2, Third2 with one report on each.&amp;nbsp; What am I doing wrong?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;ods excel file="C:\TEST_EXAMPLE.xlsx" &lt;BR /&gt;options(sheet_interval='bygroup' sheet_name="#byval1") ;&lt;/P&gt;
&lt;P&gt;proc report data=test;&lt;BR /&gt;by ORDER;&lt;BR /&gt;column A;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc report data=test ;&lt;BR /&gt;by ORDER;&lt;BR /&gt;column B;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;ods excel close;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 19:50:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-an-output-with-two-separate-proc-report-on-each-tab/m-p/897258#M354541</guid>
      <dc:creator>KatLinden</dc:creator>
      <dc:date>2023-10-04T19:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: Need an output with two separate proc report on each tab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-an-output-with-two-separate-proc-report-on-each-tab/m-p/897263#M354543</link>
      <description>When you want two per page, you cannot use BY group processing. You can either manually use start page option or create a macro to process this. &lt;BR /&gt;&lt;BR /&gt;See this tutorial on converting this to a macro.&lt;BR /&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;</description>
      <pubDate>Wed, 04 Oct 2023 20:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-an-output-with-two-separate-proc-report-on-each-tab/m-p/897263#M354543</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-10-04T20:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need an output with two separate proc report on each tab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-an-output-with-two-separate-proc-report-on-each-tab/m-p/897266#M354545</link>
      <description>&lt;P&gt;You aren't doing anything "wrong".&amp;nbsp; If you have two procedures that have to run in parallel you have to control things tighter. #Byval is the value &lt;STRONG&gt;in one procedure call.&lt;/STRONG&gt; So if you want to call the report so that "First" appears from two different procedures you have to force that behavior.&amp;nbsp; Your example data is likely way simpler than reality otherwise I would ask what is wrong with showing columns A and B in the same table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would turn on/off sheet starts to "reset" the output to a new sheet, then use "none" to get related different procedure calls onto the same sheet.&amp;nbsp; Select the specific data with WHERE statements and manually set the names.&lt;/P&gt;
&lt;PRE&gt;ods excel file="C:\TEST_EXAMPLE.xlsx"
options(sheet_interval='none' sheet_name="First") ;

proc report data=test;
Where ORDER='First';
column A;

run;

proc report data=test ;
Where ORDER='First';
column B;
run;

ods excel options(sheet_interval='proc');
ods excel options(sheet_interval='none' Sheet_name='Second');

proc report data=test;
Where ORDER='Second';
column A;

run;

proc report data=test ;
Where ORDER='Second';
column B;
run;

ods excel options(sheet_interval='proc');
ods excel options(sheet_interval='none' Sheet_name='Third');

proc report data=test;
Where ORDER='Third';
column A;

run;

proc report data=test ;
Where ORDER='Third';
column B;
run;


ods excel close;

&lt;/PRE&gt;
&lt;P&gt;Possibly you might be able to restructure your data and make a different procedure call but would have to see very complete example of the complete data and reports to tell if that might be possible.&lt;/P&gt;
&lt;P&gt;People have used the SAS macro language to do such group processing or similar can be accomplished by using a data set with the items that change, such are the values of Order and using a data step with that data set and CALL EXECUTE statements to write the blocks of values.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 20:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-an-output-with-two-separate-proc-report-on-each-tab/m-p/897266#M354545</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-10-04T20:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need an output with two separate proc report on each tab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-an-output-with-two-separate-proc-report-on-each-tab/m-p/897293#M354561</link>
      <description>The macro tutorial works fine except for the fact that it creates one file per group instead of separate tabs in the same file.</description>
      <pubDate>Thu, 05 Oct 2023 01:27:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-an-output-with-two-separate-proc-report-on-each-tab/m-p/897293#M354561</guid>
      <dc:creator>KatLinden</dc:creator>
      <dc:date>2023-10-05T01:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need an output with two separate proc report on each tab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-an-output-with-two-separate-proc-report-on-each-tab/m-p/897434#M354635</link>
      <description>The example does do that, your use case is slightly different &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; You'd need to move the ODS EXCEL creation outside of the macro and then the start page within the macro for your use case. If you post the code, I can help with the changes.</description>
      <pubDate>Thu, 05 Oct 2023 17:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-an-output-with-two-separate-proc-report-on-each-tab/m-p/897434#M354635</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-10-05T17:18:37Z</dc:date>
    </item>
  </channel>
</rss>

