<?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: proc export date formats in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-export-date-formats/m-p/610778#M177930</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37449"&gt;@TimCampbell&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have had similar problems, including leading zeroes in numbers, and has lived without a solution until ODS Excel was introduced. So I don't think you have done anything wrong. It seems to be two different engines with ODS excel giving you better control over the way Excel presents the output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Morale: SAS and Excel were not born under the same sun, and they should never meet....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;Erik&lt;/P&gt;</description>
    <pubDate>Tue, 10 Dec 2019 17:11:41 GMT</pubDate>
    <dc:creator>ErikLund_Jensen</dc:creator>
    <dc:date>2019-12-10T17:11:41Z</dc:date>
    <item>
      <title>proc export date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-export-date-formats/m-p/610756#M177914</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have some code that is using proc export to output two datasets as separate sheets in an excel workbook.&lt;/P&gt;
&lt;P&gt;The recipient of the file has asked me to change the format of the dates in the spreadsheet but this is turning out not to be as simple as I thought.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the example code below I create a dates table with 3 columns a date formatted as date9, a DDMMYY10. (what our end user wants) and then a character version just for completeness.&lt;/P&gt;
&lt;P&gt;when the data ends up in the spreadsheet however...&lt;/P&gt;
&lt;P&gt;on 'MySheet1' the outdate columns is formatted with hyphens (date11. not date9.) and the fmtdate doesn't have the leading zero for the day.&lt;/P&gt;
&lt;P&gt;then on 'MySheet2' the dates for fmtdate are also formatted with hyphens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I end up with nothing formatted as date9. and the actual date format I want only working when created as text.&lt;/P&gt;
&lt;P&gt;Does anyone have any idea what is going on?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dates;
	format outdate date9. fmtdate DDMMYY10. chardate $10.;

	do outdate='01jan2019'd to '31jan2019'd;
		fmtdate=outdate;
		chardate=put(outdate,DDMMYY10.);
		output;
	end;
run;

proc export
	data = dates
	dbms = xlsx
	outfile = "/pathtofile/TestExcel.xlsx"
	replace;
	sheet="MySheet1";
run;
proc export
	data = dates
	dbms = xlsx
	outfile = "/pathtofile/TestExcel.xlsx"
	replace;
	sheet="MySheet2";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sheet1" style="width: 295px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34598i631BDF7D57436997/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="Sheet1" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Sheet1&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sheet2" style="width: 293px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34597iD48CDFD2D420840B/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="Sheet2" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Sheet2&lt;/span&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;We have a workaround using ods excel and proc print (below) to create the spreadsheet which works fine (apart from the date9 format and that the 'style=' option seems to be ignored) so it isn't business critical to get this resolved but it would be useful to know what I am doing wrong.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file = "/pathtofile/TestExcel2.xlsx";
ods excel options(sheet_name="MySheet1");
proc print data=dates noobs style=minimal;
run;

ods excel options(sheet_name="MySheet2");
proc print data=dates noobs style=minimal;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ods excel" style="width: 296px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34599i1084A2E6FE79EF95/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="ods excel" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;ods excel&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tim&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 15:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-export-date-formats/m-p/610756#M177914</guid>
      <dc:creator>TimCampbell</dc:creator>
      <dc:date>2019-12-10T15:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc export date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-export-date-formats/m-p/610778#M177930</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37449"&gt;@TimCampbell&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have had similar problems, including leading zeroes in numbers, and has lived without a solution until ODS Excel was introduced. So I don't think you have done anything wrong. It seems to be two different engines with ODS excel giving you better control over the way Excel presents the output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Morale: SAS and Excel were not born under the same sun, and they should never meet....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;Erik&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 17:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-export-date-formats/m-p/610778#M177930</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-12-10T17:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: proc export date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-export-date-formats/m-p/610782#M177931</link>
      <description>&lt;P&gt;If you want Excel to display dates in a particular style you need to tell Excel that.&amp;nbsp; I don't think PROC EXPORT (or the XLSX libname engine) actually tells Excel anything specific and so it just defaults to how your installation of EXCEL likes to display dates.&lt;/P&gt;
&lt;P&gt;ODS EXCEL does a better job of guessing what style to tell EXCEL to use. And it allows you to use the TAGATTR style attribute to override its defaults.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/ODS-Export-Date-to-Excel-Properly/td-p/392280" target="_self"&gt;Please read the responses on this other question&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 17:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-export-date-formats/m-p/610782#M177931</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-10T17:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: proc export date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-export-date-formats/m-p/610939#M178014</link>
      <description>&lt;P&gt;Thanks Tom,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Searching for TAGATTR gave me all the answers I needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For future reference this page below helped a lot, also showed me where to put the style=minimal option to get it to work properly.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings10/031-2010.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings10/031-2010.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here is the final version of the code that works for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dates;
	format outdate date9. fmtdate DDMMYY10. chardate $10.;

	do outdate='01jan2019'd to '31jan2019'd;
		fmtdate=outdate;
		chardate=put(outdate,DDMMYY10.);
		output;
	end;
run;

ods excel file = "/pathtofile/TestExcel2.xlsx" style=minimal;
ods excel options(sheet_name="MySheet1");
proc print data=dates noobs;
	var outdate fmtdate / style=[tagattr='format:dd/mm/yyyy'];
	var chardate;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tim&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 10:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-export-date-formats/m-p/610939#M178014</guid>
      <dc:creator>TimCampbell</dc:creator>
      <dc:date>2019-12-11T10:02:43Z</dc:date>
    </item>
  </channel>
</rss>

