<?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: ODS Excel - proc print by in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-proc-print-by/m-p/465278#M20979</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I don't open Excel files. If data is presented in a DATA step program I am more inclined to try to run and fix the program. However, reading your code, and using SASHELP.SHOES, I came up with a mockup of what I think your report looks like. I used PROC REPORT for the BY group report in order to show you the difference between using a TITLE statement to get what you want and using PROC REPORT and a COMPUTE block:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mockup_report.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20789iA0753C543F6D2D5B/image-size/large?v=v2&amp;amp;px=999" role="button" title="mockup_report.png" alt="mockup_report.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The strings shown with '1)' are from a TITLE2 statement. To get extra space between the title and the previous table, you need to use TITLE1 to put a blank line before TITLE2. Instead of using the default BYLINE, I turned it off and used #BYVAL1 and #BYVAL2 in the TITLE2 statement (with j=l) to left justify the string and put the BY group values into the title area.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Compare that to the strings shown with '2)' -- those strings also identify the Region and Product, but "inside" the boundary of the table and using the same colors as the Header. The string is also left justified.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The program below uses both techniques, you'll have to decide which works best for your data and your overall program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.shoes out=shoes;
  by region product;
  where region in ('Asia', 'Canada');
run;
   
ods excel file="c:\temp\test_report_eng.xlsx" style = normal
options(embedded_titles="yes");
 
***** First table;
ods excel options (sheet_name = 'Dealership' 
    sheet_interval = "none" tab_color='grey' 
    orientation = "landscape");
proc print data=shoes(obs=3)  noobs;
title1 justify=left bold "Salesreport";
where region = "Asia";
var region sales returns inventory;
run;
title;

**** Space in between the first and second table;
 proc odstext;
p " " /style=[color=black backgroundcolor=white];
run;
 &lt;BR /&gt;&lt;BR /&gt;***** Second group of tables using BY group processing;&lt;BR /&gt;***** but since sheet_interval=none, all tables will be on same sheet;&lt;BR /&gt;***** NOTE, second sheet_name suboption will NOT be used because first;&lt;BR /&gt;***** sheet_name option is the name of the active sheet;&lt;BR /&gt;ods excel options (sheet_name = 'With PROC REPORT' &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sheet_interval = "none" );&lt;BR /&gt;options nobyline;&lt;BR /&gt;title1 ' ';&lt;BR /&gt;title2 j=l bold c=black '1) Region: #byval1 Product: #byval2';&lt;BR /&gt;&lt;BR /&gt;proc report data=shoes ;&lt;BR /&gt;where region = "Asia";&lt;BR /&gt;by region product;&lt;BR /&gt;column region product subsidiary returns inventory sales;&lt;BR /&gt;define region / group noprint;&lt;BR /&gt;define product / group noprint;&lt;BR /&gt;break before region / page;&lt;BR /&gt;compute before _page_/style=Header{just=l color=black font_weight=bold};&lt;BR /&gt;&amp;nbsp; brkline = catx(' ','2) Region and Product:',region, product);&lt;BR /&gt;&amp;nbsp; line brkline $varying50.;&lt;BR /&gt;endcomp;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;ods excel close;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 26 May 2018 17:55:49 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2018-05-26T17:55:49Z</dc:date>
    <item>
      <title>ODS Excel - proc print by</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-proc-print-by/m-p/464994#M20977</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create an Excel sheet for a lot of dealers, consisting of two spread sheets - one for each dealer called Dealership and one with graphics. I excluded the code for the graphics, because this part of the Excel is formatted the way I want it to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the dealership sheet, I want to see some sales figures for the whole dealer and beneath it by salesperson. The code I use is attached and the result&amp;nbsp;is in "test_print_eng.xls".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The thing that I want to change is that the name of the second sales person is very close to the table of the first sales person.&lt;/P&gt;&lt;P&gt;Is there any way that I can use styles or any other method to get more space in between the table and the header of the second sales person?&amp;nbsp;In order to make the Excel look prettier - see "test_print_eng - wished results" (either aligned left or centered, is fine for me).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I searched the web but I didn't find something on styles and the by statement in the proc print.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that another solution would be to generate a table for each sales person of a dealer, but I would like to use proc print and by to do the trick.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 09:01:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-proc-print-by/m-p/464994#M20977</guid>
      <dc:creator>Michael_Sch</dc:creator>
      <dc:date>2018-05-25T09:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel - proc print by</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-proc-print-by/m-p/465258#M20978</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/143177"&gt;@Michael_Sch&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;May be consider using Proc Report instead as this procedures provides much more flexibility for tweaking your output the way you want it.&lt;/P&gt;</description>
      <pubDate>Sat, 26 May 2018 10:15:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-proc-print-by/m-p/465258#M20978</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-26T10:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel - proc print by</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-proc-print-by/m-p/465278#M20979</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I don't open Excel files. If data is presented in a DATA step program I am more inclined to try to run and fix the program. However, reading your code, and using SASHELP.SHOES, I came up with a mockup of what I think your report looks like. I used PROC REPORT for the BY group report in order to show you the difference between using a TITLE statement to get what you want and using PROC REPORT and a COMPUTE block:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mockup_report.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20789iA0753C543F6D2D5B/image-size/large?v=v2&amp;amp;px=999" role="button" title="mockup_report.png" alt="mockup_report.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The strings shown with '1)' are from a TITLE2 statement. To get extra space between the title and the previous table, you need to use TITLE1 to put a blank line before TITLE2. Instead of using the default BYLINE, I turned it off and used #BYVAL1 and #BYVAL2 in the TITLE2 statement (with j=l) to left justify the string and put the BY group values into the title area.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Compare that to the strings shown with '2)' -- those strings also identify the Region and Product, but "inside" the boundary of the table and using the same colors as the Header. The string is also left justified.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The program below uses both techniques, you'll have to decide which works best for your data and your overall program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.shoes out=shoes;
  by region product;
  where region in ('Asia', 'Canada');
run;
   
ods excel file="c:\temp\test_report_eng.xlsx" style = normal
options(embedded_titles="yes");
 
***** First table;
ods excel options (sheet_name = 'Dealership' 
    sheet_interval = "none" tab_color='grey' 
    orientation = "landscape");
proc print data=shoes(obs=3)  noobs;
title1 justify=left bold "Salesreport";
where region = "Asia";
var region sales returns inventory;
run;
title;

**** Space in between the first and second table;
 proc odstext;
p " " /style=[color=black backgroundcolor=white];
run;
 &lt;BR /&gt;&lt;BR /&gt;***** Second group of tables using BY group processing;&lt;BR /&gt;***** but since sheet_interval=none, all tables will be on same sheet;&lt;BR /&gt;***** NOTE, second sheet_name suboption will NOT be used because first;&lt;BR /&gt;***** sheet_name option is the name of the active sheet;&lt;BR /&gt;ods excel options (sheet_name = 'With PROC REPORT' &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sheet_interval = "none" );&lt;BR /&gt;options nobyline;&lt;BR /&gt;title1 ' ';&lt;BR /&gt;title2 j=l bold c=black '1) Region: #byval1 Product: #byval2';&lt;BR /&gt;&lt;BR /&gt;proc report data=shoes ;&lt;BR /&gt;where region = "Asia";&lt;BR /&gt;by region product;&lt;BR /&gt;column region product subsidiary returns inventory sales;&lt;BR /&gt;define region / group noprint;&lt;BR /&gt;define product / group noprint;&lt;BR /&gt;break before region / page;&lt;BR /&gt;compute before _page_/style=Header{just=l color=black font_weight=bold};&lt;BR /&gt;&amp;nbsp; brkline = catx(' ','2) Region and Product:',region, product);&lt;BR /&gt;&amp;nbsp; line brkline $varying50.;&lt;BR /&gt;endcomp;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;ods excel close;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 May 2018 17:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-proc-print-by/m-p/465278#M20979</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-05-26T17:55:49Z</dc:date>
    </item>
  </channel>
</rss>

