<?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: convert number to date error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719152#M222638</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212695"&gt;@Phil_NZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry it is my fault, yes, I just run &lt;STRONG&gt;proc contents&lt;/STRONG&gt; and yes BDATE is a character variable.&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;, could you please hint me what do you mean by replacing&amp;nbsp;&lt;STRONG&gt;34624 &lt;/STRONG&gt;by&lt;STRONG&gt; "appropriate variable name" ?&amp;nbsp;&lt;/STRONG&gt;I did not get the idea this time then...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks and warm regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I asked to adapt your code and this is what you ran:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data &amp;amp;outfm.merge2_(drop=NAME BDATE);
 	set &amp;amp;outfm.merge2;
    xldt_delta = '30dec1899'd;
    dt=34624 + xldt_delta; put dt= ddmmyy10.;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As BDATE is char type, the adapted code should be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data &amp;amp;outfm.merge2_(drop=NAME BDATE);
 	set &amp;amp;outfm.merge2;
    xldt_delta = '30dec1899'd;
	if upcase(bdate) ne 'NA' and not missing(bdate)
	then dt=input(bdate,?? &amp;lt;bdate informat&amp;gt;) + xldt_delta;
	put dt= ddmmyy10.; /* mark line for production */&lt;BR /&gt;    format dt ddmmyy10.;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if bdate contains number like 34624 then the informat should be 5.&lt;/P&gt;</description>
    <pubDate>Sat, 13 Feb 2021 21:45:38 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2021-02-13T21:45:38Z</dc:date>
    <item>
      <title>convert number to date error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719092#M222607</link>
      <description>&lt;P&gt;Hi all SAS Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Today I tried to convert from number (automatically transported from excel to SAS) back to the date.&lt;/P&gt;
&lt;P&gt;Shortly, I want to change from&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Type           BDATE
134495         34624
134625         34325
13811D         37432
149482         34701&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Type         BDATE
134495     17/10/1994
134625     22/12/1993
13811D     25/06/2002
149482     2/01/1995&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The code is as below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ARGENTINA_merge2_(drop=NAME BDATE);  
 set ARGENTINA_merge2;  
SASDATE = input(BDATE,32.)+'30DEC1899'd ; 
put SASDATE= yymmdd10.; 
 yr=input(year, ?? 32.); 
 run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, SAS inform this error message:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Invalid argument to function INPUT&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Actually I follow &lt;A href="https://communities.sas.com/t5/SAS-Programming/Converting-date-to-number-forth-and-back/td-p/715730" target="_self"&gt;this post&lt;/A&gt; to form the conversion of SASDATE, but do not understand why it does not work this time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warm regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2021 10:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719092#M222607</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-02-13T10:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: convert number to date error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719094#M222609</link>
      <description>&lt;P&gt;&lt;STRONG&gt;ALWAYS&lt;/STRONG&gt; post the complete log of a step.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2021 11:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719094#M222609</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-13T11:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: convert number to date error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719096#M222611</link>
      <description>&lt;P&gt;heck next code and adapt your program:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 xldt_delta = '30dec1899'd;
 dt=34624 + xldt_delta; put dt= ddmmyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Feb 2021 11:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719096#M222611</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-13T11:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: convert number to date error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719098#M222613</link>
      <description>SASDATE = input(BDATE,32.)+'30DEC1899'd ; &lt;BR /&gt;--&amp;gt;&lt;BR /&gt;SASDATE = BDATE+'30DEC1899'd ; &lt;BR /&gt;&lt;BR /&gt;BDATE is numeric not character type .</description>
      <pubDate>Sat, 13 Feb 2021 12:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719098#M222613</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-02-13T12:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: convert number to date error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719128#M222623</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data is numeric, not character, because when I change the code to what you mentioned, the error log as below appears&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ARGENTINA_merge2_(drop=NAME BDATE);   &lt;BR /&gt;  set ARGENTINA_merge2;  &lt;BR /&gt;  SASDATE = BDATE +'30DEC1899'd ; &lt;BR /&gt;  format SASDATE yymmdd10.;  &lt;BR /&gt;  yr=input(year, ?? 32.);  &lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;134       +               data ARGENTINA_merge2_(drop=NAME BDATE);   set ARGENTINA_merge2;  SASDATE = BDATE +'30DEC1899'd ;  format 
SASDATE yymmdd10.;  yr=input(year, ?? 32.);  run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      134:92   
NOTE: Invalid numeric data, BDATE='NA' , at line 134 column 92.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Warm regards!&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2021 18:56:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719128#M222623</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-02-13T18:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: convert number to date error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719131#M222625</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While I put a code like that into my code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data &amp;amp;outfm.merge2_(drop=NAME BDATE);
 	set &amp;amp;outfm.merge2;
    xldt_delta = '30dec1899'd;
    dt=34624 + xldt_delta; put dt= ddmmyy10.;

 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It seems to work, but there are two issues here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. It shows a long list of date in the log&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994
dt=17/10/1994&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2. When it shows the dt in the log correctly, in the output, it does not show like that&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_0-1613243203316.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54700i3A94CC216F1A1CF0/image-size/large?v=v2&amp;amp;px=999" role="button" title="My97_0-1613243203316.png" alt="My97_0-1613243203316.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please help me to sort it out?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2021 19:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719131#M222625</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-02-13T19:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: convert number to date error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719132#M222626</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212695"&gt;@Phil_NZ&lt;/a&gt;, did you not notice that the literal number&amp;nbsp;&lt;STRONG&gt;34624&lt;/STRONG&gt; is just the first &lt;STRONG&gt;BDAT&lt;/STRONG&gt; value in your data set? Replace the number with the appropriate data variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Corresponding with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;I see you got a message:&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;Invalid numeric data, BDATE='NA' , at line 134 column 92.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It seems that BDAT is a char type? What does NA mean for you?&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2021 19:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719132#M222626</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-13T19:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: convert number to date error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719135#M222629</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry it is my fault, yes, I just run &lt;STRONG&gt;proc contents&lt;/STRONG&gt; and yes BDATE is a character variable.&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;, could you please hint me what do you mean by replacing&amp;nbsp;&lt;STRONG&gt;34624 &lt;/STRONG&gt;by&lt;STRONG&gt; "appropriate variable name" ?&amp;nbsp;&lt;/STRONG&gt;I did not get the idea this time then...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks and warm regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2021 19:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719135#M222629</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-02-13T19:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: convert number to date error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719152#M222638</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212695"&gt;@Phil_NZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry it is my fault, yes, I just run &lt;STRONG&gt;proc contents&lt;/STRONG&gt; and yes BDATE is a character variable.&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;, could you please hint me what do you mean by replacing&amp;nbsp;&lt;STRONG&gt;34624 &lt;/STRONG&gt;by&lt;STRONG&gt; "appropriate variable name" ?&amp;nbsp;&lt;/STRONG&gt;I did not get the idea this time then...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks and warm regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I asked to adapt your code and this is what you ran:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data &amp;amp;outfm.merge2_(drop=NAME BDATE);
 	set &amp;amp;outfm.merge2;
    xldt_delta = '30dec1899'd;
    dt=34624 + xldt_delta; put dt= ddmmyy10.;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As BDATE is char type, the adapted code should be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data &amp;amp;outfm.merge2_(drop=NAME BDATE);
 	set &amp;amp;outfm.merge2;
    xldt_delta = '30dec1899'd;
	if upcase(bdate) ne 'NA' and not missing(bdate)
	then dt=input(bdate,?? &amp;lt;bdate informat&amp;gt;) + xldt_delta;
	put dt= ddmmyy10.; /* mark line for production */&lt;BR /&gt;    format dt ddmmyy10.;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if bdate contains number like 34624 then the informat should be 5.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2021 21:45:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-number-to-date-error/m-p/719152#M222638</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-13T21:45:38Z</dc:date>
    </item>
  </channel>
</rss>

