<?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 Converting numeric dates to date format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-dates-to-date-format/m-p/730363#M227427</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following set of numeric dates which I need to convert into a date format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;10161&lt;BR /&gt;10164&lt;BR /&gt;10168&lt;BR /&gt;10169&lt;BR /&gt;10170&lt;BR /&gt;10171&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;for example the first value represent 01JAN1961 but some values can represent dates in this century too.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have attempted&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;PRE&gt;DATE &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN&gt;Input&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;(&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN&gt;Put&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;(&lt;/SPAN&gt; MyDate&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;8&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; date9.&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;but have failed.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Any help will be appreciated&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks in advance !&lt;/DIV&gt;</description>
    <pubDate>Wed, 31 Mar 2021 11:24:55 GMT</pubDate>
    <dc:creator>Adnan2</dc:creator>
    <dc:date>2021-03-31T11:24:55Z</dc:date>
    <item>
      <title>Converting numeric dates to date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-dates-to-date-format/m-p/730363#M227427</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following set of numeric dates which I need to convert into a date format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;10161&lt;BR /&gt;10164&lt;BR /&gt;10168&lt;BR /&gt;10169&lt;BR /&gt;10170&lt;BR /&gt;10171&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;for example the first value represent 01JAN1961 but some values can represent dates in this century too.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have attempted&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;PRE&gt;DATE &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN&gt;Input&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;(&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN&gt;Put&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;(&lt;/SPAN&gt; MyDate&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;8&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; date9.&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;but have failed.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Any help will be appreciated&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks in advance !&lt;/DIV&gt;</description>
      <pubDate>Wed, 31 Mar 2021 11:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-dates-to-date-format/m-p/730363#M227427</guid>
      <dc:creator>Adnan2</dc:creator>
      <dc:date>2021-03-31T11:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric dates to date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-dates-to-date-format/m-p/730367#M227428</link>
      <description>&lt;P&gt;Important clarification: the values are numeric, but they are not SAS date values. SAS date values are the number of days since 01JAN1960, and so January 1, 2020 is represented as 21915 in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Important clarification: when you provide dates, the first part of the date (either day or month, it's not clear which this is from your description) must be TWO digits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, in your cases, you can use the Z6. format on 10161, making the first part of the date now having two digits, and then the code should work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
    mydate=10161;
    DATE = put( mydate, z6.);
    numdate = input(date,mmddyy6.);
    format numdate date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and also you must clarify does date come first or does month come first in your inputs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV&gt;I have attempted&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;DATE &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN&gt;Input&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;(&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN&gt;Put&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;(&lt;/SPAN&gt; MyDate&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;8&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; date9.&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;but have failed.&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;This code can't possibly work, it has unbalanced parentheses and is missing a semicolon.&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 12:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-dates-to-date-format/m-p/730367#M227428</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-31T12:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric dates to date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-dates-to-date-format/m-p/730369#M227429</link>
      <description>&lt;P&gt;I take it that the last 2 digits are the year, the next 2 digits to the &lt;STRIKE&gt;right&lt;/STRIKE&gt; left of the year is the day-of-month (even if the day-of-month is less than 10), and the leading 1 (or 2) digits is the month, correct?&amp;nbsp; In other words, your values are either 5 or 6 digits, depending on the month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the cutoff value for years assigned to the 20th century (19xx) and years in the 21st century?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 11:54:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-dates-to-date-format/m-p/730369#M227429</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-03-31T11:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric dates to date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-dates-to-date-format/m-p/730381#M227433</link>
      <description>&lt;P&gt;Can you be sure about DMY or MDY order? And that the second part will always have 2 digits?&lt;/P&gt;
&lt;P&gt;Otherwise, 10161 could mean 1961-01-01, 1961-01-10 or 1961-10-01.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 12:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-dates-to-date-format/m-p/730381#M227433</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-31T12:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric dates to date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-dates-to-date-format/m-p/730405#M227441</link>
      <description>&lt;P&gt;What sort of file did you read to bring the data into SAS?&lt;/P&gt;
&lt;P&gt;If that file was text and showed these dates as 010160 then you just need to use the proper format when reading the data to begin with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 14:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-dates-to-date-format/m-p/730405#M227441</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-31T14:41:32Z</dc:date>
    </item>
  </channel>
</rss>

