<?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 How to read such a date format in SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-such-a-date-format-in-SAS/m-p/171008#M264251</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have imported an input file, which has date in the form: &lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="64"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="64"&gt; 20.06.2011&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Most of the fields are empty which read like '"-".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how do i get the date out of such format, its currently read in character format&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Jul 2014 15:57:31 GMT</pubDate>
    <dc:creator>munitech4u</dc:creator>
    <dc:date>2014-07-08T15:57:31Z</dc:date>
    <item>
      <title>How to read such a date format in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-such-a-date-format-in-SAS/m-p/171008#M264251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have imported an input file, which has date in the form: &lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="64"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="64"&gt; 20.06.2011&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Most of the fields are empty which read like '"-".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how do i get the date out of such format, its currently read in character format&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 15:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-such-a-date-format-in-SAS/m-p/171008#M264251</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2014-07-08T15:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to read such a date format in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-such-a-date-format-in-SAS/m-p/171009#M264252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ddmmyy informat will read this appropriately and specify missing for those that aren't. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How have you specified your informat for this variable?&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000197977.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000197977.htm"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H1&gt;&lt;A name="a000197977"&gt;DDMMYY&lt;SPAN class="emph"&gt;w&lt;/SPAN&gt;. Informat&lt;/A&gt;&lt;/H1&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;&lt;SPAN class="shortDesc"&gt;Reads date values in the form &lt;SPAN class="emph"&gt;ddmmyy&amp;lt;yy&amp;gt;&lt;/SPAN&gt; or &lt;SPAN class="emph"&gt;dd-mm-yy&amp;lt;yy&amp;gt;&lt;/SPAN&gt;, where a special character, such as a hyphen (-), period (.), or slash (/), separates the day, month, and year; the year can be either 2 or 4 digits.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 16:25:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-such-a-date-format-in-SAS/m-p/171009#M264252</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-07-08T16:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to read such a date format in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-such-a-date-format-in-SAS/m-p/171010#M264253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; You did not explain how you are doing the import (PROC IMPORT, DATA step program) or what your original file is (Excel, text file, CSV, etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; When you say that "most of the fields are empty" -- usually, SAS would read "empty" fields as missing numeric (a single dot) or missing character (a single space). So a hyphen or dash for missing is odd.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; But, if your date is a character string and you want to create a numeric variable with a date value (number of days since Jan 1, 1960), then the INPUT function is what you need to use. For example, let's assume that your character variable was called &lt;STRONG&gt;CHARDATE&lt;/STRONG&gt; and that it had a text string of 15.11.1950 (which you wanted to convert to the number -3334, which represents a SAS date value for Nov 15, 1950). Then you would use the INPUT function like this (in a program):&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;newdatevar= input(chardate,anydtdte10.);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;altdatevar = input(chardate,ddmmyy10.);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; Where ANYDTDTE or DDMMYY are the "informats" that you need to use to convert your character string INTO a SAS date value with the INPUT function. But if you are using a DATA step program to read your data in the first place, it might be easier to read the data in an INPUT statement like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;INPUT numvar : anydtdte. ;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; But whichever method you use, you will need an INFORMAT such as ANYDTDTE or DDMMYY in order to read or convert the date value correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; Then, the value for the variables would be -3334, internally, and if you wanted to see them as meaningful dates, you would use a SAS format statement like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;format newdatevar altdatevar mmddyy10.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 16:36:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-such-a-date-format-in-SAS/m-p/171010#M264253</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2014-07-08T16:36:59Z</dc:date>
    </item>
  </channel>
</rss>

