<?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: Convert SAS date to text in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517628#M3363</link>
    <description>&lt;P&gt;Since a date is a count of days, and a datetime a count of seconds, you only need to multiply with 86400 wherever you need the datetime, or use the dhms() function.&lt;/P&gt;
&lt;P&gt;Note that your wanted value is useless except for display.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Nov 2018 20:01:10 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-11-30T20:01:10Z</dc:date>
    <item>
      <title>Convert SAS date to text</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517624#M3362</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use the macro variable DATE defined below&lt;/P&gt;&lt;P&gt;%LET DATE = '29NOV2018'D;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to create another macro variable that looks like this.&lt;/P&gt;&lt;P&gt;%LET DATETIME = '2018-11-29 00:00:00.0000000';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 19:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517624#M3362</guid>
      <dc:creator>pradark1</dc:creator>
      <dc:date>2018-11-30T19:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to text</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517628#M3363</link>
      <description>&lt;P&gt;Since a date is a count of days, and a datetime a count of seconds, you only need to multiply with 86400 wherever you need the datetime, or use the dhms() function.&lt;/P&gt;
&lt;P&gt;Note that your wanted value is useless except for display.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 20:01:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517628#M3363</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-30T20:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to text</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517629#M3364</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/186420"&gt;@pradark1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to use the macro variable DATE defined below&lt;/P&gt;
&lt;P&gt;%LET DATE = '29NOV2018'D;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to create another macro variable that looks like this.&lt;/P&gt;
&lt;P&gt;%LET DATETIME = '2018-11-29 00:00:00.0000000';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I achieve this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use DHMS function. Note the second parameter in SYSFUNC is the format. The default will be a datetime that's numeric, to have is shown as indicated you need to apply a format, in this case I've used datetime. Note that applying a display format makes it more difficult to use in the future because you need quotes and dt at the end, whereas the numerical variable will be interpreted correctly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let datetime = %sysfunc(dhms(&amp;amp;date., 0, 0, 0), datetime.);
%put &amp;amp;datetime.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 20:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517629#M3364</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-30T20:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to text</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517631#M3365</link>
      <description>Guys, I want the date to be displayed as a text string due to how it is used in my database. so being able to use the following format is important. I want the right hand side of the equation below to be another macro that converts to text like below.&lt;BR /&gt;%LET DATETIME = '2018-11-29 00:00:00.0000000';</description>
      <pubDate>Fri, 30 Nov 2018 20:06:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517631#M3365</guid>
      <dc:creator>pradark1</dc:creator>
      <dc:date>2018-11-30T20:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to text</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517636#M3366</link>
      <description>&lt;P&gt;Your display format can be achieved with the e8601dt. format and filtering out the "T", or by rolling your own format with proc format.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 20:12:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517636#M3366</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-30T20:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to text</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517637#M3367</link>
      <description>&lt;P&gt;And please note that not everybody here is male. Using "guys" when addressing our most prolific solution provider is sexist at best.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 20:14:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517637#M3367</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-30T20:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date to text</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517645#M3369</link>
      <description>Here is a solution:&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;length datetime $ 30;&lt;BR /&gt;datetime = trim(put(&amp;amp;date,YYMMDD10.)) || " 00:00:00.0000000";&lt;BR /&gt;call symput("datetime",datetime);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%put Datetime= &amp;amp;datetime.;</description>
      <pubDate>Fri, 30 Nov 2018 20:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-SAS-date-to-text/m-p/517645#M3369</guid>
      <dc:creator>pradark1</dc:creator>
      <dc:date>2018-11-30T20:32:17Z</dc:date>
    </item>
  </channel>
</rss>

