<?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 time formats in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24894#M4264</link>
    <description>Consider simplifying your code, for the "input" side - here is an example:&lt;BR /&gt;
&lt;BR /&gt;
data _null_; &lt;BR /&gt;
var1 = 'Nov 30 2008 12:08 AM'; &lt;BR /&gt;
format INPUT_VAR_DT_MM datetime. ;&lt;BR /&gt;
INPUT_VAR_DT_MM = input(var1,anydtdtm.); &lt;BR /&gt;
put _all_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Thu, 30 Apr 2009 18:38:45 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-04-30T18:38:45Z</dc:date>
    <item>
      <title>Date time formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24889#M4259</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Would someone please let me know hw to convert this date to CCYYMMDD format.&lt;BR /&gt;
&lt;BR /&gt;
Jun 31 2007 12:00AM&lt;BR /&gt;
&lt;BR /&gt;
thanks,&lt;BR /&gt;
sasbase9</description>
      <pubDate>Wed, 29 Apr 2009 09:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24889#M4259</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-29T09:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Date time formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24890#M4260</link>
      <description>There is no such date as jun 31 !! &lt;BR /&gt;
&lt;BR /&gt;
June only has 30 days &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 29 Apr 2009 11:11:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24890#M4260</guid>
      <dc:creator>GertNissen</dc:creator>
      <dc:date>2009-04-29T11:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Date time formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24891#M4261</link>
      <description>In a DATA step, you would use the appropriate INFORMAT with either an INPUT statement or INPUT function to parse the character string to a SAS numeric variable that represents a "date" (important for choosing your INFORMAT).&lt;BR /&gt;
&lt;BR /&gt;
Then you must convert the "date" variable to be a "datetime" variable likely using the DHMS function - my preference.&lt;BR /&gt;
&lt;BR /&gt;
Here's a general example that reads a date character string in a particular input format, converting to a date, and then assigning a new variable as a datetime:&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;&lt;BR /&gt;
format mydate date9. ;&lt;BR /&gt;
INPUT mydate yymmdd8.;&lt;BR /&gt;
format mydatetime datetime21. ;&lt;BR /&gt;
mydatetime = dhms(mydate,0,0,0);&lt;BR /&gt;
putlog _all_;&lt;BR /&gt;
datalines&lt;BR /&gt;
20090101&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website has technical documentation and supplemental conference and sample papers on this type of topic - I have provided links below for reference.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Dates, Times, and Intervals &lt;BR /&gt;
About SAS Date, Time, and Datetime Values&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a002200738.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a002200738.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Reading Raw Data&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001112330.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001112330.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
SAS 9.2 Language Reference: Dictionary - SAS INFORMATs and FORMATs are documented here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/titlepage.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/titlepage.htm&lt;/A&gt;</description>
      <pubDate>Wed, 29 Apr 2009 12:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24891#M4261</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-04-29T12:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Date time formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24892#M4262</link>
      <description>Hi, &lt;BR /&gt;
&lt;BR /&gt;
Thanks SBB to reply back. I tried using below logic in my data set.&lt;BR /&gt;
&lt;BR /&gt;
INPUT_VAR_DT_MM		= PUT(month(PUT(input(var1,date9.),10.)),Z2.) ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
but it is not working. Our date on raw file is Like I said above , for ex : Nov 30 2008 12:08 AM.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Can you pls again let me know what needs to be corrected in my above logic.&lt;BR /&gt;
&lt;BR /&gt;
thanks for help,&lt;BR /&gt;
sasbase9</description>
      <pubDate>Thu, 30 Apr 2009 09:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24892#M4262</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-30T09:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Date time formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24893#M4263</link>
      <description>Try [pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
 var1 = 'Nov 30 2008 12:08 AM';&lt;BR /&gt;
 INPUT_VAR_DT_MM = input(scan(var1,2)!!scan(var1,1)!!scan(var1,3), date9.);&lt;BR /&gt;
 put INPUT_VAR_DT_MM= INPUT_VAR_DT_MM= date.;&lt;BR /&gt;
run;[/pre]&lt;BR /&gt;
This will give you a SAS date (not datetime)!</description>
      <pubDate>Thu, 30 Apr 2009 13:04:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24893#M4263</guid>
      <dc:creator>GertNissen</dc:creator>
      <dc:date>2009-04-30T13:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Date time formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24894#M4264</link>
      <description>Consider simplifying your code, for the "input" side - here is an example:&lt;BR /&gt;
&lt;BR /&gt;
data _null_; &lt;BR /&gt;
var1 = 'Nov 30 2008 12:08 AM'; &lt;BR /&gt;
format INPUT_VAR_DT_MM datetime. ;&lt;BR /&gt;
INPUT_VAR_DT_MM = input(var1,anydtdtm.); &lt;BR /&gt;
put _all_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 30 Apr 2009 18:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-time-formats/m-p/24894#M4264</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-04-30T18:38:45Z</dc:date>
    </item>
  </channel>
</rss>

