<?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: Maintaining date-time format when export to Excel file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741412#M231765</link>
    <description>&lt;P&gt;Use special style 'tagattr'.&lt;BR /&gt;&lt;BR /&gt;proc report data=test2 nowd;&lt;BR /&gt;define datetime/style={tagattr='format:yyyy/m/d h:mm&amp;nbsp; &amp;nbsp; type:datetime'};&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt; have many post about this style .&lt;/P&gt;</description>
    <pubDate>Fri, 14 May 2021 13:12:30 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-05-14T13:12:30Z</dc:date>
    <item>
      <title>Maintaining date-time format when export to Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741245#M231685</link>
      <description>&lt;P&gt;I have a SAS data set with date-time values like &lt;STRONG&gt;28AUG20:10:18:59&lt;/STRONG&gt;. Since I want them in a customized format, I wrote the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture dtpic
other='%Y-%0m-%0d %0H:%0M:%0S' (datatype=datetime)
;
data test2; set test1;
   format admitdttm dtpic.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So my date-time values are like&amp;nbsp;&lt;STRONG&gt;2020-08-28 10:18:59&lt;/STRONG&gt; which is how I want them to be formatted. The problem comes when I try to export the data set to Excel. I've tried PROC EXPORT, as well as the following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file="C:\vvvv\Phase 1\DATA\Results\Gath.xlsx";
proc report data=test2
columns _all_;
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;No luck. I'm using SAS 9.4 TS Level 1M2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 19:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741245#M231685</guid>
      <dc:creator>DocMartin</dc:creator>
      <dc:date>2021-05-13T19:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Maintaining date-time format when export to Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741257#M231691</link>
      <description>&lt;P&gt;So what is the problem?&lt;/P&gt;
&lt;P&gt;No values in Excel?&lt;/P&gt;
&lt;P&gt;Values but they don't look like the SAS format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure that Excel has a "custom" date time format to handle the converted datetime values. Do you get a "standard" datetime appearance in Excel if you use a basic SAS Datetime format? If so try getting an EXCEL format to display the values properly. Once you know what that looks like you can use a style override for the variable with the TAGATTR option to define the Excel target format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 19:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741257#M231691</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-13T19:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Maintaining date-time format when export to Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741261#M231694</link>
      <description>&lt;P&gt;It depends on how I'm trying to export to Excel. If I use PROC EXPORT I just get the original date-time format that I had used. If I try with ODS Excel, an error occurs in Excel and no data is sent to the file.&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 19:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741261#M231694</guid>
      <dc:creator>DocMartin</dc:creator>
      <dc:date>2021-05-13T19:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Maintaining date-time format when export to Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741269#M231696</link>
      <description>&lt;P&gt;Update your SAS installation.&amp;nbsp; 9.4m2 is almost 7 years old.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2013/08/02/how-old-is-your-version-of-sas-release-dates-for-sas-software.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2013/08/02/how-old-is-your-version-of-sas-release-dates-for-sas-software.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming your admission timestamp was in this century:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture dtpic
other='%Y-%0m-%0d %0H:%0M:%0S' (datatype=datetime)
;
data test2;
   admitdttm = '28AUG2020:10:18:59'dt;
   format admitdttm dtpic.;
run;

ods excel file="C:\downloads\dt.xlsx";
proc report data=test2;
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS Results:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 186px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59374i4BC20B73B78E12CE/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Excel Results:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 255px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59375iF3A6AD366D4BA4F2/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 20:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741269#M231696</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-13T20:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Maintaining date-time format when export to Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741272#M231699</link>
      <description>&lt;P&gt;Getting close. Here's what was exported to the Excel file:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;hadmit&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2020-08-28&lt;BR /&gt;10:18:59&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know why a carriage return was inserted into the format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the version of SAS that my university lets professors have. Ugh!&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 20:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741272#M231699</guid>
      <dc:creator>DocMartin</dc:creator>
      <dc:date>2021-05-13T20:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Maintaining date-time format when export to Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741276#M231702</link>
      <description>&lt;P&gt;Tell them they are wasting their money and your time by forcing you to use out-dated software.&amp;nbsp; They are already paying for the newer version as part of their license fees.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is an option for tell ODS EXCEL not to insert line breaks to wrap long text strings.&amp;nbsp; But that also is easier with newer version of SAS.&amp;nbsp; I think there was an old workaround for that from before the enhancement added the easy to use option.&amp;nbsp; That might work in your version.&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 21:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741276#M231702</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-13T21:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Maintaining date-time format when export to Excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741412#M231765</link>
      <description>&lt;P&gt;Use special style 'tagattr'.&lt;BR /&gt;&lt;BR /&gt;proc report data=test2 nowd;&lt;BR /&gt;define datetime/style={tagattr='format:yyyy/m/d h:mm&amp;nbsp; &amp;nbsp; type:datetime'};&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt; have many post about this style .&lt;/P&gt;</description>
      <pubDate>Fri, 14 May 2021 13:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Maintaining-date-time-format-when-export-to-Excel-file/m-p/741412#M231765</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-14T13:12:30Z</dc:date>
    </item>
  </channel>
</rss>

