<?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 create SAS date from numeric date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571693#M161295</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create SAS date from numeric date.&lt;/P&gt;
&lt;P&gt;In the code I get null value. why?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*create sas date from numeric date */
Data a;
x=20181029;
Run;

data b;
set a;
yy=substr(put(x,8.),3,2)*1;
mm=substr(put(x,8.),7,2)*1;
dd=substr(put(x,8.),5,2)*1;
new_x = mdy(mm, dd, yy); 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Jul 2019 05:02:43 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2019-07-08T05:02:43Z</dc:date>
    <item>
      <title>create SAS date from numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571693#M161295</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create SAS date from numeric date.&lt;/P&gt;
&lt;P&gt;In the code I get null value. why?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*create sas date from numeric date */
Data a;
x=20181029;
Run;

data b;
set a;
yy=substr(put(x,8.),3,2)*1;
mm=substr(put(x,8.),7,2)*1;
dd=substr(put(x,8.),5,2)*1;
new_x = mdy(mm, dd, yy); 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jul 2019 05:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571693#M161295</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-07-08T05:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: create SAS date from numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571696#M161298</link>
      <description>Why so complicated? Just use something like new_x = input (cats(x), yymmdd10.))</description>
      <pubDate>Mon, 08 Jul 2019 05:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571696#M161298</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-07-08T05:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: create SAS date from numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571697#M161299</link>
      <description>&lt;P&gt;Year starts at position 1, month at position 5, day at position 7.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 05:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571697#M161299</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-07-08T05:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: create SAS date from numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571699#M161301</link>
      <description>&lt;P&gt;Year starts from 1 and takes 4 positions&lt;/P&gt;
&lt;P&gt;Month starts from 5th taking 2 positions&lt;/P&gt;
&lt;P&gt;day starts from 7th taking 2 positions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, modify your substr() function. You will get the right answer.&lt;/P&gt;
&lt;PRE&gt;data b;
set a;
yy=substr(put(x,8.),1,4)*1;
mm=substr(put(x,8.),5,2)*1;
dd=substr(put(x,8.),7,2)*1;
new_x = mdy(mm, dd, yy); 
put new_x = date10.;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 05:29:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571699#M161301</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-07-08T05:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: create SAS date from numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571701#M161302</link>
      <description>&lt;P&gt;What is the purpose of using&amp;nbsp;cats function in this case?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 05:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571701#M161302</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-07-08T05:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: create SAS date from numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571702#M161303</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What is the purpose of using&amp;nbsp;cats function in this case?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The cats-functions helps avoiding the note (or error) complaining about automatic type conversion.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 05:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571702#M161303</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-07-08T05:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: create SAS date from numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571714#M161306</link>
      <description>&lt;P&gt;Why so complicated?&lt;/P&gt;
&lt;P&gt;Do it in one statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data a;
x=20181029;
Run;

data b;
set a;
new_x = input(put(x,z8.),yymmdd8.);
format new_x yymmddd10.;
put new_x=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log excerpt:&lt;/P&gt;
&lt;PRE&gt;28         data b;
29         set a;
30         new_x = input(put(x,z8.),yymmdd8.);
31         format new_x yymmddd10.;
32         put new_x=;
33         run;

new_x=2018-10-29&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jul 2019 08:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571714#M161306</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-08T08:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: create SAS date from numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571915#M161357</link>
      <description>&lt;P&gt;Specifically why: the error in the value you supplied to MDY function:&lt;/P&gt;
&lt;PRE&gt;1860  data b;
1861  set a;
1862  yy=substr(put(x,8.),3,2)*1;
1863  mm=substr(put(x,8.),7,2)*1;
1864  dd=substr(put(x,8.),5,2)*1;
1865  new_x = mdy(mm, dd, yy);
1866  run;

NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      1862:4   1863:4   1864:4
NOTE: Invalid argument to function MDY(29,10,18) at line 1865 column 9.
x=20181029 yy=18 mm=29 dd=10 new_x=. _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The results of the
      operations have been set to missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 at 1865:9
&lt;/PRE&gt;
&lt;P&gt;MONTH must be 1 to 12. Day values acceptable will depend on the year and month. Getting value of 29 for MM should have been a clue that the date string was parsed incorrectly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While you may get the correct date with a two digit year why bother to go to the work to ignore the provided full 4 digit year????&lt;/P&gt;
&lt;P&gt;And as pointed out, a proper informat may be a better choice.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 22:07:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-SAS-date-from-numeric-date/m-p/571915#M161357</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-08T22:07:38Z</dc:date>
    </item>
  </channel>
</rss>

