<?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: 01JUN2011:00:00:00 Convert To SAS Date... in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13923#M2096</link>
    <description>It is important to understand that the value stored is not the value you "see" if it has a format associated with the variable.&lt;BR /&gt;
&lt;BR /&gt;
SAS does not have a date variable type.  It has variables that are either numeric and character.  If it is numeric, and it "looks" like one of the date strings asked about in this thread, then the variable MUST be formatted.  You will want to use one of the many functions to break apart a SAS date, datetime, or time value.&lt;BR /&gt;
&lt;BR /&gt;
SAS stores all dates, times, and datetime values as numbers, just numbers.  If it seems to look like something else it either has a format or it is a character string and needs to be converted to an appropriate number (days or seconds).  Again a function is used.</description>
    <pubDate>Wed, 22 Jun 2011 06:23:27 GMT</pubDate>
    <dc:creator>ArtC</dc:creator>
    <dc:date>2011-06-22T06:23:27Z</dc:date>
    <item>
      <title>01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13914#M2087</link>
      <description>I have a SAS Dataset that originated from Access.&lt;BR /&gt;
All dates look like 01JUN2011:00:00:00&lt;BR /&gt;
What is the correct informat synatx to to convert the above format into a SAS Serial Date. Is it datetime18.0 but I cant get it to work.&lt;BR /&gt;
Thanks, Jay</description>
      <pubDate>Wed, 15 Jun 2011 01:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13914#M2087</guid>
      <dc:creator>JaySwan</dc:creator>
      <dc:date>2011-06-15T01:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13915#M2088</link>
      <description>try the INPUT function.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data dates;&lt;BR /&gt;
 cdate='01JUN2011:10:41:27';&lt;BR /&gt;
 datetime = input(cdate,datetime18.);&lt;BR /&gt;
 date = datepart(datetime);&lt;BR /&gt;
 put cdate=;&lt;BR /&gt;
 put datetime= datetime= datetime18.;&lt;BR /&gt;
 put date= date= date9.;&lt;BR /&gt;
 run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
the LOG shows&lt;BR /&gt;
[pre]cdate=01JUN2011:10:41:27&lt;BR /&gt;
datetime=1622544087 datetime=01JUN11:10:41:27&lt;BR /&gt;
date=18779 date=01JUN2011&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 15 Jun 2011 02:30:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13915#M2088</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-06-15T02:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13916#M2089</link>
      <description>Thanks for the help...&lt;BR /&gt;
Your test works fine..&lt;BR /&gt;
&lt;BR /&gt;
But when I read in the actual variable I get this in the log...&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Numeric values have been converted to character &lt;BR /&gt;
      values at the places given by: (Line):(Column).&lt;BR /&gt;
      119:27   120:28   121:25   &lt;BR /&gt;
NOTE: Invalid argument to function INPUT at line 119 column 21.&lt;BR /&gt;
NOTE: Invalid argument to function INPUT at line 120 column 22.&lt;BR /&gt;
NOTE: Invalid argument to function INPUT at line 121 column 19.&lt;BR /&gt;
&lt;BR /&gt;
ReqEffectiveDate=01DEC2004:00:00:00&lt;BR /&gt;
AppReceivedDate=22NOV2004:00:00:00&lt;BR /&gt;
ActualEffDate=01DEC2004:00:00:00&lt;BR /&gt;
&lt;BR /&gt;
SAppReceivedDate=.&lt;BR /&gt;
SReqEffectiveDate=.&lt;BR /&gt;
SActualEffDate=.&lt;BR /&gt;
&lt;BR /&gt;
_ERROR_=1 _N_=1&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
With this code, so there is something SAS does not like...&lt;BR /&gt;
&lt;BR /&gt;
SAppReceivedDate = input(AppReceivedDate,datetime18.); &lt;BR /&gt;
SReqEffectiveDate = input(ReqEffectiveDate,datetime18.); &lt;BR /&gt;
SActualEffDate = input(ActualEffDate,datetime18.);</description>
      <pubDate>Wed, 15 Jun 2011 04:12:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13916#M2089</guid>
      <dc:creator>JaySwan</dc:creator>
      <dc:date>2011-06-15T04:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13917#M2090</link>
      <description>Without seeing more of your code and the data it is a bit hard to be definitive.  Perhaps the incoming value is not actually character but is already a formatted datetime value.  How have you verified that this is not the case.  Are the conversion notes being generated by the statements that you have flagged? All that we can be sure of at this point is that something is not what it seems on first glance.</description>
      <pubDate>Wed, 15 Jun 2011 04:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13917#M2090</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-06-15T04:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13918#M2091</link>
      <description>Yep, the data in the orig Access dataset is of type date with a length of 8 and looks like this 01DEC2004:00:00:00&lt;BR /&gt;
&lt;BR /&gt;
Her is my current code, still working on this.&lt;BR /&gt;
Still not converting the AppReceivedDate into a SAS Serial Date...&lt;BR /&gt;
&lt;BR /&gt;
data xxx.xxx;&lt;BR /&gt;
    Length CAppReceivedDate $18;&lt;BR /&gt;
    Set xxx.xxx;&lt;BR /&gt;
         CAppReceivedDate = AppReceivedDate; /*Access Date*/&lt;BR /&gt;
         /* format new char var into SAS Dataset Date */&lt;BR /&gt;
         SAppReceivedDate = input(CAppReceivedDate,datetime18.);&lt;BR /&gt;
         Date = Datepart(SAppReceivedDate);&lt;BR /&gt;
         put Date=;&lt;BR /&gt;
         put SAppReceivedDate= SAppReceivedDate=datetime18.;&lt;BR /&gt;
         put Date= date=date9.;&lt;BR /&gt;
Where Process_Date = 20110512;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 15 Jun 2011 05:22:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13918#M2091</guid>
      <dc:creator>JaySwan</dc:creator>
      <dc:date>2011-06-15T05:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13919#M2092</link>
      <description>If you're importing straight from access and its already defined as a date, then you only need to extract the date portion of the datetime variable and format it accordingly.  If process_date is a date as well, then you'll need to tell sas that it is..&lt;BR /&gt;
&lt;BR /&gt;
data xxx.xxx;&lt;BR /&gt;
Set xxx.xxx;&lt;BR /&gt;
Date = Datepart(AppReceivedDate);&lt;BR /&gt;
put Date= date=date9.;&lt;BR /&gt;
Where Process_Date = '20110512'd;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 15 Jun 2011 11:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13919#M2092</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2011-06-15T11:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13920#M2093</link>
      <description>Thanks for the help, all set..&lt;BR /&gt;
Jay</description>
      <pubDate>Wed, 15 Jun 2011 16:32:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13920#M2093</guid>
      <dc:creator>JaySwan</dc:creator>
      <dc:date>2011-06-15T16:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13921#M2094</link>
      <description>I thought the solution might help me with the date format I have but it didn't. So here's what I have: &lt;BR /&gt;
&lt;BR /&gt;
Wed May 18 16:58:32 2011&lt;BR /&gt;
&lt;BR /&gt;
How can I get only the Month Date Year ?? For ex: May 18 2011. &lt;BR /&gt;
&lt;BR /&gt;
Can you please help me out?</description>
      <pubDate>Tue, 21 Jun 2011 20:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13921#M2094</guid>
      <dc:creator>Pritish</dc:creator>
      <dc:date>2011-06-21T20:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13922#M2095</link>
      <description>Format worddate. will help you.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 22 Jun 2011 02:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13922#M2095</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-22T02:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13923#M2096</link>
      <description>It is important to understand that the value stored is not the value you "see" if it has a format associated with the variable.&lt;BR /&gt;
&lt;BR /&gt;
SAS does not have a date variable type.  It has variables that are either numeric and character.  If it is numeric, and it "looks" like one of the date strings asked about in this thread, then the variable MUST be formatted.  You will want to use one of the many functions to break apart a SAS date, datetime, or time value.&lt;BR /&gt;
&lt;BR /&gt;
SAS stores all dates, times, and datetime values as numbers, just numbers.  If it seems to look like something else it either has a format or it is a character string and needs to be converted to an appropriate number (days or seconds).  Again a function is used.</description>
      <pubDate>Wed, 22 Jun 2011 06:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13923#M2096</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-06-22T06:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13924#M2097</link>
      <description>Try this&lt;BR /&gt;
&lt;BR /&gt;
data a2(keep=dt1 dt2);&lt;BR /&gt;
input dt$ 1-30;&lt;BR /&gt;
&lt;BR /&gt;
s1=scan(dt,1);&lt;BR /&gt;
s2=scan(dt,2);&lt;BR /&gt;
s3=scan(dt,3);&lt;BR /&gt;
s4=scan(dt,4);&lt;BR /&gt;
s5=scan(dt,5);&lt;BR /&gt;
dt1=trim(compress(s3||s2||s5));&lt;BR /&gt;
dt2=input(dt1,date9.);&lt;BR /&gt;
format dt2 ddmmyy10.;&lt;BR /&gt;
cards;&lt;BR /&gt;
Wed May 18 16:58:32 2011&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 22 Jun 2011 09:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13924#M2097</guid>
      <dc:creator>sas_</dc:creator>
      <dc:date>2011-06-22T09:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13925#M2098</link>
      <description>To expand on some of the things already said...&lt;BR /&gt;
&lt;BR /&gt;
It is important to understand how your data is stored and what attributes are associated with a certain variable.  This will drive the solution.  One way to check your data - there are many - that I use frequently is the following&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  describe table xxx.xxx;&lt;BR /&gt;
&lt;BR /&gt;
This will return each column name, type (num or Char), format, informats and label.  If the date is already numeric then reformatting with a new date format will do the trick.  If the date is stored as a character variable ie Char(n) then you will have to use some sort of conversion to convert to a numeric variable that represents a date.   As for the other thread &lt;BR /&gt;
&lt;BR /&gt;
where mydate = Wed May 18 16:58:32 2011&lt;BR /&gt;
&lt;BR /&gt;
If this is a FORMATTED numeric value, something like datepart&lt;BR /&gt;
something like x = datepart(maydate); format datepart worddate.;  should give the correct results</description>
      <pubDate>Wed, 22 Jun 2011 18:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/13925#M2098</guid>
      <dc:creator>LAP</dc:creator>
      <dc:date>2011-06-22T18:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: 01JUN2011:00:00:00 Convert To SAS Date...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/234991#M54988</link>
      <description>&lt;P&gt;Try this;&lt;/P&gt;
&lt;P&gt;One more thing always add '&lt;STRONG&gt;DT&lt;/STRONG&gt;' after date time value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data dates;&lt;BR /&gt;date = '01JUN2011:00:00:00'dt;&lt;BR /&gt;format date datetime20.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;set dates;&lt;BR /&gt;New_Date = datepart(date);&lt;BR /&gt;New_time = timepart(date);&lt;BR /&gt;format New_Date date9. New_time hhmm10.2;&amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 11:46:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/01JUN2011-00-00-00-Convert-To-SAS-Date/m-p/234991#M54988</guid>
      <dc:creator>ManoharNath</dc:creator>
      <dc:date>2015-11-17T11:46:35Z</dc:date>
    </item>
  </channel>
</rss>

