<?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/53570#M11314</link>
    <description>Absolutely no need to be sorry.  You made my day!</description>
    <pubDate>Tue, 21 Dec 2010 22:19:00 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2010-12-21T22:19:00Z</dc:date>
    <item>
      <title>date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53556#M11300</link>
      <description>I have a text file that contain below date format&lt;BR /&gt;
&lt;BR /&gt;
12/12/2000 10:13:45&lt;BR /&gt;
23/11/2010  9:45:34&lt;BR /&gt;
&lt;BR /&gt;
I have write below mention data set but it does not comes date format .&lt;BR /&gt;
data date;&lt;BR /&gt;
infile'C:\Documents and Settings\sasadm\Desktop\date.txt' dlm='|' dsd;&lt;BR /&gt;
input x  datetime20.;&lt;BR /&gt;
format datetime20.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Please help me .</description>
      <pubDate>Tue, 21 Dec 2010 16:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53556#M11300</guid>
      <dc:creator>arpit</dc:creator>
      <dc:date>2010-12-21T16:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53557#M11301</link>
      <description>Hi:&lt;BR /&gt;
  It clearly says in the documentation that the DATETIME informat requires that the date value to be read &lt;U&gt;must&lt;/U&gt; be in the form as described:&lt;BR /&gt;
&lt;B&gt;&lt;BR /&gt;
The datetime values must be in the following form: ddmmmyy or ddmmmyyyy, followed by a blank or special character, followed by hh:mm:ss.ss (the time). &lt;/B&gt;&lt;BR /&gt;
from this doc site:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000199624.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000199624.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
One of your dates to be read is: 23/11/2010 9:45:34 and this is not a format that DATETIME will read. Your date should be&lt;BR /&gt;
23NOV2010 9:45:34 in order for the DATETIME informat to work. &lt;BR /&gt;
&lt;BR /&gt;
You will need to look for another INFORMAT (such as ANYDTDTM.) :&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a002605552.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a002605552.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
Also, for a FORMAT statement to work, you must list the variable to be formatted in the FORMAT statement. So this is incorrect:&lt;BR /&gt;
[pre]&lt;BR /&gt;
format datetime20.;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                     &lt;BR /&gt;
If you are reading variable X, and if X is read with the correct INFORMAT, then the appropriate FORMAT statement would be:&lt;BR /&gt;
[pre]&lt;BR /&gt;
format X datetime20.;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 21 Dec 2010 17:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53557#M11301</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-12-21T17:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53558#M11302</link>
      <description>Dear Cyntha,&lt;BR /&gt;
&lt;BR /&gt;
But i got this date format from exel.i.e in DD/MM/YY HH:MM:SS&lt;BR /&gt;
&lt;BR /&gt;
How i convert this into sas date format.&lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot for ur kind cooperation &lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Arpit</description>
      <pubDate>Tue, 21 Dec 2010 17:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53558#M11302</guid>
      <dc:creator>arpit</dc:creator>
      <dc:date>2010-12-21T17:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53559#M11303</link>
      <description>Arpit,&lt;BR /&gt;
&lt;BR /&gt;
I think that the method described in the following tip might be exactly what you are looking for: &lt;A href="http://www.sascommunity.org/wiki/Tip_of_the_Day:August_27" target="_blank"&gt;http://www.sascommunity.org/wiki/Tip_of_the_Day:August_27&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
If one has date/time data that includes a space between the date and time, you can read it directly with the anydtdtm informat as long as you put an ampersand, after the variable in the input statement.  The tip shows example code.&lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art</description>
      <pubDate>Tue, 21 Dec 2010 17:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53559#M11303</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-12-21T17:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53560#M11304</link>
      <description>Hi:&lt;BR /&gt;
  Just because Excel gives the date in that format does not automatically mean that the DATETIME informat in SAS will read it. If your date does indeed look like&lt;BR /&gt;
 DD/MM/YY HH:MM:SS, then as suggested (twice now) you will need to use &lt;B&gt;another&lt;/B&gt; informat to read the value. &lt;BR /&gt;
&lt;BR /&gt;
  The ANYDTDTM informat should work for you and you have a link to the documentation in my post and a link to a tip in another posting that should help you figure out what to do.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 21 Dec 2010 18:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53560#M11304</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-12-21T18:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53561#M11305</link>
      <description>Dear Art,&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
options datestyle=dmy;&lt;BR /&gt;
 &lt;BR /&gt;
data have;&lt;BR /&gt;
  informat datetime anydtdtm18.;&lt;BR /&gt;
  format date date9.;&lt;BR /&gt;
  format time time8.;&lt;BR /&gt;
  input datetime &amp;amp;;&lt;BR /&gt;
  date=datepart(datetime);&lt;BR /&gt;
  time=timepart(datetime);&lt;BR /&gt;
cards;&lt;BR /&gt;
14/9/2007 11:25:59&lt;BR /&gt;
12/7/2010 15:25:59&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
This code generate below output&lt;BR /&gt;
&lt;BR /&gt;
datetime       date             time&lt;BR /&gt;
1505388359  14SEP2007 11:25:59&lt;BR /&gt;
1594567559  12JUL2010  15:25:59&lt;BR /&gt;
&lt;BR /&gt;
it show 3 column&lt;BR /&gt;
but I want in below mention format&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
datetime&lt;BR /&gt;
14/09/2007 11:25:59&lt;BR /&gt;
12/06/2010 15:25:59&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks for ur kind information.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
ARPIT</description>
      <pubDate>Tue, 21 Dec 2010 18:15:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53561#M11305</guid>
      <dc:creator>arpit</dc:creator>
      <dc:date>2010-12-21T18:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53562#M11306</link>
      <description>I could not get it&lt;BR /&gt;
&lt;BR /&gt;
Please help me out</description>
      <pubDate>Tue, 21 Dec 2010 18:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53562#M11306</guid>
      <dc:creator>arpit</dc:creator>
      <dc:date>2010-12-21T18:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53563#M11307</link>
      <description>Hi:&lt;BR /&gt;
  Once you have read your variable successfully, the number is stored internally as the number of SECONDS since January 1, 1960. so, as you can see from your "separated" DATE and TIME variables, you have successfully extracted the values from the internally stored number.&lt;BR /&gt;
&lt;BR /&gt;
  The way to control the DISPLAY of a variable (especially a variable whose value represents a date, a time or a date/time) is through the use of a FORMAT generally a statement (but for some procedures it is the FORMAT option). You have applied a FORMAT to the DATE variable (DATE9.) and to the TIME variable (time8.) in the following statements:&lt;BR /&gt;
[pre]&lt;BR /&gt;
format date date9.;&lt;BR /&gt;
format time time8.;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                 &lt;BR /&gt;
But just because you used an INFORMAT to read the value of the DATETIME variable, a FORMAT will not automatically be applied. An INFORMAT only controls how a variable is read INTO SAS. A FORMAT controls how a variable is DISPLAYED, such as with PROC PRINT or any reporting procedure.&lt;BR /&gt;
 &lt;BR /&gt;
So, you will need to apply a FORMAT to the DATETIME variable, such as:&lt;BR /&gt;
[pre]&lt;BR /&gt;
format date date9. time time8. datetime datetime20.;&lt;BR /&gt;
OR&lt;BR /&gt;
format date ddmmyy10. time time8. datetime E8601DT20.;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
To find out the available list of formats to use for your DATETIME variable, you can search the documentation for the topic "Functions by Category". I show two possible formats above. If the available pre-defined formats are not adequate to your needs, then PROC FORMAT allows the use of "date-time directives" in order to give you the opportunity to format date and time and date/time variables in almost any fashion you want.&lt;BR /&gt;
 &lt;BR /&gt;
The documentation on the use of date-time directives with PROC FORMAT is here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473467.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473467.htm&lt;/A&gt; (looks specifically at using DATATYPE= and how to specify values for the PICTURE statement.)&lt;BR /&gt;
&lt;BR /&gt;
and some other useful information is here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/24/621.html" target="_blank"&gt;http://support.sas.com/kb/24/621.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi31/243-31.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi31/243-31.pdf&lt;/A&gt; (picture formats for date/time variables starts on page 14 -- but the rest of the paper is worth reading, too.)&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 21 Dec 2010 19:29:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53563#M11307</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-12-21T19:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53564#M11308</link>
      <description>Hello Arpit,&lt;BR /&gt;
&lt;BR /&gt;
I did not find the exact format you requested. I see 2 possible solutions:&lt;BR /&gt;
1) you agree to use DateTime18. format for the datetime variable or&lt;BR /&gt;
2) it is possible to make a character variable dt in the requested format.&lt;BR /&gt;
&lt;BR /&gt;
See code below:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
length dt $20;&lt;BR /&gt;
informat datetime anydtdtm18.;&lt;BR /&gt;
format date MMDDYY10.;&lt;BR /&gt;
format time time8.;&lt;BR /&gt;
input datetime &amp;amp;;&lt;BR /&gt;
date=datepart(datetime);&lt;BR /&gt;
time=timepart(datetime);&lt;BR /&gt;
dt=put(date,MMDDYY10.)||" "||put(time,time8.);&lt;BR /&gt;
format datetime Datetime18.;&lt;BR /&gt;
cards;&lt;BR /&gt;
14/9/2007 11:25:59&lt;BR /&gt;
12/7/2010 15:25:59&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 21 Dec 2010 19:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53564#M11308</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-12-21T19:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53565#M11309</link>
      <description>If I correctly understand, you were able to read the data, but now need a format for outputting it the same way?&lt;BR /&gt;
&lt;BR /&gt;
While not just roll your own format?  I can't test the following at the moment, but it should work:&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
  picture mydate other='%0d/%0m/%0Y %0H:%0M:%0S' (datatype=datetime);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data want;&lt;BR /&gt;
  set have;&lt;BR /&gt;
  format datetime mydate.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Art</description>
      <pubDate>Tue, 21 Dec 2010 20:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53565#M11309</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-12-21T20:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53566#M11310</link>
      <description>Hello ArtC,&lt;BR /&gt;
&lt;BR /&gt;
It perfectly works!&lt;BR /&gt;
&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 21 Dec 2010 20:21:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53566#M11310</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-12-21T20:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53567#M11311</link>
      <description>Glad to hear that, but I'm not ArtC.  I'm ArtT</description>
      <pubDate>Tue, 21 Dec 2010 20:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53567#M11311</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-12-21T20:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53568#M11312</link>
      <description>And I am honored to have been mistaken for ArtT!!</description>
      <pubDate>Tue, 21 Dec 2010 21:10:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53568#M11312</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2010-12-21T21:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53569#M11313</link>
      <description>Sorry ArtT,&lt;BR /&gt;
&lt;BR /&gt;
It was my mistake.&lt;BR /&gt;
&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 21 Dec 2010 21:57:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53569#M11313</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-12-21T21:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53570#M11314</link>
      <description>Absolutely no need to be sorry.  You made my day!</description>
      <pubDate>Tue, 21 Dec 2010 22:19:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53570#M11314</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-12-21T22:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53571#M11315</link>
      <description>it work properly&lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot SPR for your kind information.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
ARPIT</description>
      <pubDate>Wed, 22 Dec 2010 16:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/53571#M11315</guid>
      <dc:creator>arpit</dc:creator>
      <dc:date>2010-12-22T16:28:26Z</dc:date>
    </item>
  </channel>
</rss>

