<?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: Date Format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504389#M134971</link>
    <description>&lt;P&gt;Why would you want to store values that are clearly DATE values into a DATETIME variable?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do that you will need make up a timepart.&amp;nbsp;Do you want to assume the timepart is zero (ie Midnight).&lt;/P&gt;</description>
    <pubDate>Mon, 15 Oct 2018 17:24:20 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-10-15T17:24:20Z</dc:date>
    <item>
      <title>Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504378#M134962</link>
      <description>&lt;P&gt;Hi, I am seeking for help on formatting a date variable.&amp;nbsp;Please see the example as below.&lt;/P&gt;&lt;P&gt;I would like to format the date1 variable from char $12. to num (length 8, final format DATETIME. and informat&amp;nbsp;ANYDTDTM40). The solution&amp;nbsp;I have thought about is firstly &lt;U&gt;to remove the comma and make the date1 into &lt;/U&gt;01Aug2018&lt;U&gt; format&lt;/U&gt; (then I know how to process further),&lt;U&gt; but how can I achieve this first step (the underlined)&lt;/U&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or, any other solutions/ suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much. I really appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*1-raw data*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id date1 $12.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 Aug 01, 2018&lt;BR /&gt;2 Aug 16, 2018&lt;BR /&gt;3 Jul 17, 2018&lt;BR /&gt;4 Sep 30, 2018&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*2-solution?*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 16:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504378#M134962</guid>
      <dc:creator>cpulala</dc:creator>
      <dc:date>2018-10-15T16:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504380#M134964</link>
      <description>&lt;P&gt;You will need to create a new variable.&amp;nbsp; DATE1 is already character, and can't be changed to numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;date1 = cat(scan(date1, 2, ', ').&amp;nbsp;scan(date1, 1, ', '), scan(date1, 3, ', '));&lt;/P&gt;
&lt;P&gt;date2 = input(date1, date9.);&lt;/P&gt;
&lt;P&gt;format date2 date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 16:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504380#M134964</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-10-15T16:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504381#M134965</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id date1 $12.;
datalines;
1 Aug 01, 2018
2 Aug 16, 2018
3 Jul 17, 2018
4 Sep 30, 2018
;
run;

data want;
set have;
new_d=input(date1,anydtdte21.);
format new_d date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Oct 2018 16:41:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504381#M134965</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T16:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504383#M134966</link>
      <description>&lt;P&gt;Thank you so much! One typo&amp;nbsp;after SCAN function - should be "," instead of "."&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 16:52:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504383#M134966</guid>
      <dc:creator>cpulala</dc:creator>
      <dc:date>2018-10-15T16:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504384#M134967</link>
      <description>&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 16:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504384#M134967</guid>
      <dc:creator>cpulala</dc:creator>
      <dc:date>2018-10-15T16:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504389#M134971</link>
      <description>&lt;P&gt;Why would you want to store values that are clearly DATE values into a DATETIME variable?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do that you will need make up a timepart.&amp;nbsp;Do you want to assume the timepart is zero (ie Midnight).&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 17:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504389#M134971</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-15T17:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504472#M134999</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/98121"&gt;@cpulala&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I am seeking for help on formatting a date variable.&amp;nbsp;Please see the example as below.&lt;/P&gt;
&lt;P&gt;I would like to format the date1 variable from char $12. to num (length 8, final format DATETIME. and informat&amp;nbsp;ANYDTDTM40). The solution&amp;nbsp;I have thought about is firstly &lt;U&gt;to remove the comma and make the date1 into &lt;/U&gt;01Aug2018&lt;U&gt; format&lt;/U&gt; (then I know how to process further),&lt;U&gt; but how can I achieve this first step (the underlined)&lt;/U&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, any other solutions/ suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much. I really appreciate it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*1-raw data*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input id date1 $12.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 Aug 01, 2018&lt;BR /&gt;2 Aug 16, 2018&lt;BR /&gt;3 Jul 17, 2018&lt;BR /&gt;4 Sep 30, 2018&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*2-solution?*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Unless you have some other program examining informats specifically there is seldom a reason to force the informat assignment. If so, the ANDTDTM would be a last choice as it indicates you didn't know what format your data was going to come from.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 20:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504472#M134999</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-15T20:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504498#M135011</link>
      <description>&lt;P&gt;Somebody who uses R for the next step requires the datetime. format for date.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 21:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504498#M135011</guid>
      <dc:creator>cpulala</dc:creator>
      <dc:date>2018-10-15T21:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504547#M135034</link>
      <description>I am pretty sure that R can handle reading DATE variables from SAS.  I certainly hope so since you marked a solution that is create a DATE variable as the correct solution for your problem.&lt;BR /&gt;In SAS a date is stored as the number of days and a datetime is stored as the number of seconds.  You can convert from DATETIME to DATE using the DATEPART() function.  You can convert from DATE to DATETIME use the DHMS() function (Days,Hours,Minutes,Seconds) by using the date value for the first argument and whatever time of day you want to use for the Hour, Minute and Second arguments. Normally you would use zeros.&lt;BR /&gt;</description>
      <pubDate>Tue, 16 Oct 2018 00:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504547#M135034</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-16T00:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504758#M135130</link>
      <description>&lt;P&gt;Thanks for the suggestions.&amp;nbsp;It does not matter if R can handle it or not; it is just requirements.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So did you mean that I was not choosing a correct solution? But I did not see any error when transferring it back to DATE format, and so I chose it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 15:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format/m-p/504758#M135130</guid>
      <dc:creator>cpulala</dc:creator>
      <dc:date>2018-10-16T15:43:46Z</dc:date>
    </item>
  </channel>
</rss>

