<?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: Keep format of time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/759600#M240081</link>
    <description>&lt;P&gt;If you really start with a SAS datetime value then using the timepart() should do what you need.&lt;/P&gt;
&lt;P&gt;Below code leads to the result you're after.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  datetime=datetime();
  time=timepart(datetime);
  format datetime datetime21. time time8. ;
  put time=;
run;
proc export data=have(keep=time)
  outfile="c:\temp\have.xlsx"
  dbms=xlsx 
  replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1628132448936.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62284iC7658E741401A719/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1628132448936.png" alt="Patrick_0-1628132448936.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Aug 2021 03:01:01 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-08-05T03:01:01Z</dc:date>
    <item>
      <title>Keep format of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758506#M239497</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my code, I have extracted the time from a datetime by using TIMEPART Function and, I would like to export my table automatically to a folder. Knowing that I have defined this column as HHMM, the output data in SAS shows the time as 08:00 (which is what I want). However, the column in the Excel's export in the folder is written as&amp;nbsp;1900-01-01 08:00:00&lt;/P&gt;&lt;P&gt;Please, how could I do to keep the format of HHMM. in my export?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 20:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758506#M239497</guid>
      <dc:creator>ElodieT</dc:creator>
      <dc:date>2021-07-30T20:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Keep format of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758528#M239511</link>
      <description>&lt;P&gt;How do you "export" the data? To what file type?&lt;/P&gt;
&lt;P&gt;If you create something like CSV you are at Microsoft's mercy as to what will happen when a text file is opened by Excel.&lt;/P&gt;
&lt;P&gt;Not much can be done at that point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are writing directly to EXCEL it may be possible to keep the formatting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show the current code you are using to export the data.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 20:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758528#M239511</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-30T20:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Keep format of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758531#M239513</link>
      <description>&lt;P&gt;Hi Ballardw,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your quick response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how I do export my data :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc export data = nametable&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;outfile = "\\path to the folder\File name.xlsx"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;dbms=excels replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;port=9621;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;server='server';&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;serveruser='user';&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;serverpass='password';&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 21:08:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758531#M239513</guid>
      <dc:creator>ElodieT</dc:creator>
      <dc:date>2021-07-30T21:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Keep format of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758545#M239522</link>
      <description>&lt;P&gt;First, if you really are using "dbms=excels ..." then your proc export issue an ERROR message to the log, and would not overwrite a pre-existing excel file.&amp;nbsp; If that excel file had Jan 1, 1900 already in place, that is what you would see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But using "excelcs" as below, I get a cell value of 0.33333... to corresponding to the 8:00AM value in SAS, per below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  time='08:00't;
  format time time8. ;
  put time=;
run;
proc export data=have
  outfile="c:\temp\have.xlsx"
  dbms=excelcs replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Opening it in Windows Excel, it shows 0.33333, which when formatted as time displays 08:00AM.&amp;nbsp; When formatted as a date, it shows 1900-01-00&amp;nbsp; (yes, "00").&amp;nbsp; &amp;nbsp;I don't know whether Excel on the mac shows the same&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 21:29:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758545#M239522</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-07-30T21:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Keep format of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758549#M239525</link>
      <description>&lt;P&gt;Hi mKeintz,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It doesn't overwrite yet because these are my first tries before putting it into production...&lt;/P&gt;&lt;P&gt;So if I understand correctly, I would have to change the format of this column manually each time once the excel file has been exported?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 21:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758549#M239525</guid>
      <dc:creator>ElodieT</dc:creator>
      <dc:date>2021-07-30T21:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Keep format of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758552#M239528</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/362698"&gt;@ElodieT&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi mKeintz,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It doesn't overwrite yet because these are my first tries before putting it into production...&lt;/P&gt;
&lt;P&gt;So if I understand correctly, I would have to change the format of this column manually each time once the excel file has been exported?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I've never needed to do any work product involving export to Excel, so I'm not qualified to answer your question.&amp;nbsp; I'm sure there are others on this forum who know all the in's and out's.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 22:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758552#M239528</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-07-30T22:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Keep format of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758570#M239542</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/362698"&gt;@ElodieT&lt;/a&gt;&amp;nbsp;Do you have to use EXCELCS? Below works for me using XLSX&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  time='08:00't;
  format time time8. ;
  put time=;
run;
proc export data=have
  outfile="c:\temp\have.xlsx"
  dbms=xlsx 
  replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1627694865577.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62161i989E7E5C4DEBE6B2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1627694865577.png" alt="Patrick_0-1627694865577.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Jul 2021 01:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/758570#M239542</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-07-31T01:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Keep format of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/759578#M240067</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the late reply. It is the column that I would like to&amp;nbsp; convert from a datetime to a time. Could I put the name of the column like 'time't to have the whole change? Or is it only for a single value? I tried and it doesn't work for the column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 01:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/759578#M240067</guid>
      <dc:creator>ElodieT</dc:creator>
      <dc:date>2021-08-05T01:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Keep format of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/759600#M240081</link>
      <description>&lt;P&gt;If you really start with a SAS datetime value then using the timepart() should do what you need.&lt;/P&gt;
&lt;P&gt;Below code leads to the result you're after.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  datetime=datetime();
  time=timepart(datetime);
  format datetime datetime21. time time8. ;
  put time=;
run;
proc export data=have(keep=time)
  outfile="c:\temp\have.xlsx"
  dbms=xlsx 
  replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1628132448936.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62284iC7658E741401A719/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1628132448936.png" alt="Patrick_0-1628132448936.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 03:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-format-of-time/m-p/759600#M240081</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-08-05T03:01:01Z</dc:date>
    </item>
  </channel>
</rss>

