<?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 Exporting to an existing excel workbook with formats in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-an-existing-excel-workbook-with-formats/m-p/527457#M22182</link>
    <description>&lt;P&gt;Dear SAS Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to generate a workbook&amp;nbsp;that has two sheets:&lt;/P&gt;&lt;P&gt;1) List of ID's, dates, groups etc.&lt;/P&gt;&lt;P&gt;2) Summary data tables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried outputting the data tables first using ods excel and then using proc export to add the list to the existing workbook, but I lose all the formatting in my dataset when I try this. I can't seem to find a way to do both online. Does anyone know the best way to accomplish this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached my code below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods noproctitle;
ods excel file="Z:\folder\file.xlsx" options(sheet_name="Summary Data" sheet_interval="none");
title 'Group Totals';
proc freq data=work.dataset; tables log_group / missing nocum; format log_group groupf.; run;

title 'Sample Totals';
proc freq data=work.dataset; tables totalplasma / missing nocum; label totalplasma='Total Plasma'; run;

title 'Log Date Types';
proc freq data=work.dataset; tables visit / missing nocum; label 
title;
ods excel close;

proc datasets library = work nolist;
	modify dataset;
	format log_group groupf.;
quit;

PROC EXPORT DATA= WORK.dataset
            OUTFILE= "Z:\folder\file.xlsx" 
            DBMS=EXCEL REPLACE;
			PUTNAMES=YES;
     SHEET="List"; 
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Cara&lt;/P&gt;</description>
    <pubDate>Tue, 15 Jan 2019 19:02:50 GMT</pubDate>
    <dc:creator>cbt2119</dc:creator>
    <dc:date>2019-01-15T19:02:50Z</dc:date>
    <item>
      <title>Exporting to an existing excel workbook with formats</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-an-existing-excel-workbook-with-formats/m-p/527457#M22182</link>
      <description>&lt;P&gt;Dear SAS Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to generate a workbook&amp;nbsp;that has two sheets:&lt;/P&gt;&lt;P&gt;1) List of ID's, dates, groups etc.&lt;/P&gt;&lt;P&gt;2) Summary data tables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried outputting the data tables first using ods excel and then using proc export to add the list to the existing workbook, but I lose all the formatting in my dataset when I try this. I can't seem to find a way to do both online. Does anyone know the best way to accomplish this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached my code below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods noproctitle;
ods excel file="Z:\folder\file.xlsx" options(sheet_name="Summary Data" sheet_interval="none");
title 'Group Totals';
proc freq data=work.dataset; tables log_group / missing nocum; format log_group groupf.; run;

title 'Sample Totals';
proc freq data=work.dataset; tables totalplasma / missing nocum; label totalplasma='Total Plasma'; run;

title 'Log Date Types';
proc freq data=work.dataset; tables visit / missing nocum; label 
title;
ods excel close;

proc datasets library = work nolist;
	modify dataset;
	format log_group groupf.;
quit;

PROC EXPORT DATA= WORK.dataset
            OUTFILE= "Z:\folder\file.xlsx" 
            DBMS=EXCEL REPLACE;
			PUTNAMES=YES;
     SHEET="List"; 
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Cara&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jan 2019 19:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-an-existing-excel-workbook-with-formats/m-p/527457#M22182</guid>
      <dc:creator>cbt2119</dc:creator>
      <dc:date>2019-01-15T19:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to an existing excel workbook with formats</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-an-existing-excel-workbook-with-formats/m-p/527487#M22183</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; This worked for me. Note that it does not use PROC EXPORT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods noproctitle;
ods excel file="c:\temp\cara_file.xlsx" style=htmlblue
    options(sheet_name="Summary Data" sheet_interval="none");
title 'Group Totals';
proc freq data=sashelp.shoes; 
tables region / missing nocum; 
run;
 
title 'Sample Totals';
proc freq data=sashelp.shoes; 
tables subsidiary / missing nocum; 
run;
 
title 'Log Date Types';
proc freq data=sashelp.shoes; 
tables product / missing nocum; 
run;
 
ods excel options(sheet_interval='table' sheet_name='List Data') style=minimal;
 
proc print  data=sashelp.shoes noobs;
format sales dollar14.2 returns dollar14. inventory dollar14.;
run;
 
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; Instead of Export, I used PROC PRINT to list the data. That allowed me to do away with the PROC DATASETS step because a format can be assigned directly in the PROC PRINT step. (And, since Excel might not respect the SAS Format, this method works as well as having a permanent format in SAS.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your titles will not show inside the sheet unless you turn on the embedded_titles suboption. With my approach, the HTMLBLUE style is used for the 1st sheet and the minimal (or black and white) is used for the 2nd sheet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jan 2019 20:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-an-existing-excel-workbook-with-formats/m-p/527487#M22183</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-01-15T20:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to an existing excel workbook with formats</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-an-existing-excel-workbook-with-formats/m-p/527495#M22184</link>
      <description>Thank you - this works well!</description>
      <pubDate>Tue, 15 Jan 2019 20:46:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-an-existing-excel-workbook-with-formats/m-p/527495#M22184</guid>
      <dc:creator>cbt2119</dc:creator>
      <dc:date>2019-01-15T20:46:07Z</dc:date>
    </item>
  </channel>
</rss>

