<?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: How can I display two proc tabulate next to each other in a excel file+ods in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-display-two-proc-tabulate-next-to-each-other-in-a/m-p/640153#M23930</link>
    <description>&lt;P&gt;Known:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN style="font-family: inherit;"&gt;There is no option to place multiple individual ODS outputs at specific locations in a specific worksheet.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-family: inherit;"&gt;You can tell ODS EXCEL the initial cell at which output is to be placed&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;ODS EXCEL OPTIONS(START_AT="&amp;lt;column&amp;gt;,&amp;lt;row&amp;gt;");&lt;/PRE&gt;
&lt;P&gt;Based on these two facts you can create a work around as follows:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Send output to a workbook (*.xlsx)
&lt;UL&gt;
&lt;LI&gt;Produce first tabulation in one worksheet&lt;/LI&gt;
&lt;LI&gt;Produce second tabulation in second worksheet&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;Run a Powershell script to open the workbook and combine the two worksheets into one&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Example:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods _all_ close;
ods noresults;

filename xlsout 'my report.xlsx';
filename script 'merge sheets.ps1';

ods excel file=xlsout;

  * first table in first worksheet;
  proc tabulate data=sashelp.cars;
    class type origin;
    table type,origin/nocellmerge;
  run;

ods excel options (start_at="6,1");

  * second table in second worksheet.
  * right of the where the first table is;
  proc tabulate data=sashelp.cars;
    class drivetrain origin;
    table drivetrain,origin/nocellmerge;
  run;

ods excel close;

* write powershell script and run it;
data _null_;
  file script;
  length outline $256;
  input;
  outline = resolve(_infile_);
  put outline;
datalines4;
$xl = new-object -c excel.application
$xl.DisplayAlerts = $false                 # prevent 'are you sure' dialogs

$wb = $xl.Workbooks.Open("%sysfunc(pathname(xlsout))") # open SAS generated Excel 

$ws1 = $wb.Worksheets(1)
$ws2 = $wb.Worksheets(2)

$row = $ws2.UsedRange.Cells(1,1).Row       # determine where paste will go
$col = $ws2.UsedRange.Cells(1,1).Column

$ws2.UsedRange.Copy()                      # copy output in 2nd sheet to clipboard
$ws1.Cells($row,$col).PasteSpecial(-4104)  # paste into 1st sheet at proper location

$ws1.Cells(1,1).Select()                   # deselect paste range
$ws2.Delete()                              # remove second sheet

$wb.Save()                                 # save without 'are you sure' dialog

$xl.quit()
;;;;

options xwait xsync xmin;

%sysexec powershell -file "%sysfunc(pathname(ps1))";

filename script;
filename xlsout;&lt;BR /&gt;ods&amp;nbsp;results;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Final saved Excel&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="side by side tabulate in excel.png" style="width: 704px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38336iD11F69F409BE4BEA/image-size/large?v=v2&amp;amp;px=999" role="button" title="side by side tabulate in excel.png" alt="side by side tabulate in excel.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2020 17:52:23 GMT</pubDate>
    <dc:creator>RichardDeVen</dc:creator>
    <dc:date>2020-04-15T17:52:23Z</dc:date>
    <item>
      <title>How can I display two proc tabulate next to each other in a excel file+ods</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-display-two-proc-tabulate-next-to-each-other-in-a/m-p/637728#M23919</link>
      <description>&lt;P&gt;Hello, I've created an excel file using ods.&lt;/P&gt;&lt;P&gt;The file contains few of proc tabulate, each one is displayed after the other one .( see screenshot)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="ask.PNG" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37935i467B0DDEAD17E390/image-size/small?v=v2&amp;amp;px=200" role="button" title="ask.PNG" alt="ask.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to display two proc tabulate next to each other , how can I do that?&lt;/P&gt;&lt;P&gt;thank you for your help&lt;/P&gt;</description>
      <pubDate>Sun, 05 Apr 2020 20:27:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-display-two-proc-tabulate-next-to-each-other-in-a/m-p/637728#M23919</guid>
      <dc:creator>kaouter</dc:creator>
      <dc:date>2020-04-05T20:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display two proc tabulate next to each other in a excel file+ods</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-display-two-proc-tabulate-next-to-each-other-in-a/m-p/637733#M23920</link>
      <description>&lt;P&gt;As far as I know, ODS EXCEL does not have the capability of displaying tables next to one another.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Apr 2020 20:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-display-two-proc-tabulate-next-to-each-other-in-a/m-p/637733#M23920</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-05T20:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display two proc tabulate next to each other in a excel file+ods</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-display-two-proc-tabulate-next-to-each-other-in-a/m-p/640153#M23930</link>
      <description>&lt;P&gt;Known:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN style="font-family: inherit;"&gt;There is no option to place multiple individual ODS outputs at specific locations in a specific worksheet.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-family: inherit;"&gt;You can tell ODS EXCEL the initial cell at which output is to be placed&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;ODS EXCEL OPTIONS(START_AT="&amp;lt;column&amp;gt;,&amp;lt;row&amp;gt;");&lt;/PRE&gt;
&lt;P&gt;Based on these two facts you can create a work around as follows:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Send output to a workbook (*.xlsx)
&lt;UL&gt;
&lt;LI&gt;Produce first tabulation in one worksheet&lt;/LI&gt;
&lt;LI&gt;Produce second tabulation in second worksheet&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;Run a Powershell script to open the workbook and combine the two worksheets into one&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Example:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods _all_ close;
ods noresults;

filename xlsout 'my report.xlsx';
filename script 'merge sheets.ps1';

ods excel file=xlsout;

  * first table in first worksheet;
  proc tabulate data=sashelp.cars;
    class type origin;
    table type,origin/nocellmerge;
  run;

ods excel options (start_at="6,1");

  * second table in second worksheet.
  * right of the where the first table is;
  proc tabulate data=sashelp.cars;
    class drivetrain origin;
    table drivetrain,origin/nocellmerge;
  run;

ods excel close;

* write powershell script and run it;
data _null_;
  file script;
  length outline $256;
  input;
  outline = resolve(_infile_);
  put outline;
datalines4;
$xl = new-object -c excel.application
$xl.DisplayAlerts = $false                 # prevent 'are you sure' dialogs

$wb = $xl.Workbooks.Open("%sysfunc(pathname(xlsout))") # open SAS generated Excel 

$ws1 = $wb.Worksheets(1)
$ws2 = $wb.Worksheets(2)

$row = $ws2.UsedRange.Cells(1,1).Row       # determine where paste will go
$col = $ws2.UsedRange.Cells(1,1).Column

$ws2.UsedRange.Copy()                      # copy output in 2nd sheet to clipboard
$ws1.Cells($row,$col).PasteSpecial(-4104)  # paste into 1st sheet at proper location

$ws1.Cells(1,1).Select()                   # deselect paste range
$ws2.Delete()                              # remove second sheet

$wb.Save()                                 # save without 'are you sure' dialog

$xl.quit()
;;;;

options xwait xsync xmin;

%sysexec powershell -file "%sysfunc(pathname(ps1))";

filename script;
filename xlsout;&lt;BR /&gt;ods&amp;nbsp;results;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Final saved Excel&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="side by side tabulate in excel.png" style="width: 704px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38336iD11F69F409BE4BEA/image-size/large?v=v2&amp;amp;px=999" role="button" title="side by side tabulate in excel.png" alt="side by side tabulate in excel.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 17:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-display-two-proc-tabulate-next-to-each-other-in-a/m-p/640153#M23930</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-04-15T17:52:23Z</dc:date>
    </item>
  </channel>
</rss>

