<?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 Help Converting Numbers to Dates!  PLEASE HELP! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/532949#M146079</link>
    <description>&lt;P&gt;I'm converting numeric dates to SAS Dates using suggestions of other users but I keep getting the following notes:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Invalid argument to function INPUT at line 80 column 16.&lt;/P&gt;&lt;P&gt;NOTE: Mathematical operations could not be performed at the following places. The results of the&lt;BR /&gt;operations have been set to missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;6 at 80:16.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used SAS code suggested by other users to convert numeric dates (e.g., 19900723) in SAS, but I've had no luck.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SAS code is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA INPHAASE.FORMATDATES;&lt;BR /&gt;SET INPHAASE.INITIALDB;&lt;BR /&gt;ABSDATE = INPUT(PUT(ABSTRACTION_DATE,8.),YYMMDD8.);&lt;BR /&gt;FORMAT ABSDATE YYMMDD8.;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd appreciate any help.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Feb 2019 15:15:07 GMT</pubDate>
    <dc:creator>rangarat</dc:creator>
    <dc:date>2019-02-05T15:15:07Z</dc:date>
    <item>
      <title>Help Converting Numbers to Dates!  PLEASE HELP!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/532949#M146079</link>
      <description>&lt;P&gt;I'm converting numeric dates to SAS Dates using suggestions of other users but I keep getting the following notes:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Invalid argument to function INPUT at line 80 column 16.&lt;/P&gt;&lt;P&gt;NOTE: Mathematical operations could not be performed at the following places. The results of the&lt;BR /&gt;operations have been set to missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;6 at 80:16.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used SAS code suggested by other users to convert numeric dates (e.g., 19900723) in SAS, but I've had no luck.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SAS code is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA INPHAASE.FORMATDATES;&lt;BR /&gt;SET INPHAASE.INITIALDB;&lt;BR /&gt;ABSDATE = INPUT(PUT(ABSTRACTION_DATE,8.),YYMMDD8.);&lt;BR /&gt;FORMAT ABSDATE YYMMDD8.;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd appreciate any help.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 15:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/532949#M146079</guid>
      <dc:creator>rangarat</dc:creator>
      <dc:date>2019-02-05T15:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Help Converting Numbers to Dates!  PLEASE HELP!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/532954#M146080</link>
      <description>&lt;P&gt;Is 19900723 really a number, or is it a character string?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is really a number, turn it into a character string first (use the CATS function, but there are many ways to do this)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
    abstraction_date=19900723;
    z=input(cats(abstraction_date),yymmdd8.);
    format z date7.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If it is a character string, the leave out the CATS function and its parentheses.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 15:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/532954#M146080</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-02-05T15:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: Help Converting Numbers to Dates!  PLEASE HELP!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/532956#M146081</link>
      <description>&lt;P&gt;First of all, stop shouting. At us and at the SAS system.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your algorithm works, as can be seen here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date_orig;
cards;
19900723
;
run;

data want;
set have;
date_correct = input(put(date_orig,8.),yymmdd8.);
format date_correct yymmddd10.;
run;

proc print data=want noobs;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;  date_          date_
  orig         correct

19900723    1990-07-23
&lt;/PRE&gt;
&lt;P&gt;So the problem has to be with your data. Maybe you have missing values, or invalid values for SAS dates.&lt;/P&gt;
&lt;P&gt;Filter formatdates for missing values of absdate, and inspect abstraction_date there.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 15:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/532956#M146081</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-05T15:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help Converting Numbers to Dates!  PLEASE HELP!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/532979#M146089</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/260059"&gt;@rangarat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm converting numeric dates to SAS Dates using suggestions of other users but I keep getting the following notes:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: Invalid argument to function INPUT at line 80 column 16.&lt;/P&gt;
&lt;P&gt;NOTE: Mathematical operations could not be performed at the following places. The results of the&lt;BR /&gt;operations have been set to missing values.&lt;BR /&gt;Each place is given by: &lt;STRONG&gt;&lt;FONT color="#0000ff"&gt;(Number of times) at (Line):(Column).&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#0000ff"&gt;6 at 80:16.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used SAS code suggested by other users to convert numeric dates (e.g., 19900723) in SAS, but I've had no luck.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS code is:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA INPHAASE.FORMATDATES;&lt;BR /&gt;SET INPHAASE.INITIALDB;&lt;BR /&gt;ABSDATE = INPUT(PUT(ABSTRACTION_DATE,8.),YYMMDD8.);&lt;BR /&gt;FORMAT ABSDATE YYMMDD8.;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd appreciate any help.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Some instruction on reading that error message: Note the "number of times" highlighted in blue refers to the 6 in the second line highlighted. If your data had more than 6 observations then this tells you the operation didn't fail for the rest. So the clue is to examine the input values of your variable abstraction_date.&lt;/P&gt;
&lt;P&gt;You can extract those observations with :&lt;/P&gt;
&lt;PRE&gt;data junk;
   set inphaase.formatdates;
   where missing(absdate);
run;&lt;/PRE&gt;
&lt;P&gt;I will suspect that when you examine the values you will find the numeric representation to of abstraction_date to be: 1) different length than 8 digits, or 2) value outside the range of 01 to 12 in the 5 and 6th digits or 3) value outside of valid number of days for a month or 4) much less likely year &amp;lt; 1581.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Common date errors for some sources are Feb 29 when not actually&amp;nbsp;a leap year or day 31 in months with only 30 days.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have received data that had a 67th day of November once.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 16:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/532979#M146089</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-05T16:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help Converting Numbers to Dates!  PLEASE HELP!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/533021#M146098</link>
      <description>&lt;P&gt;Hi Rangarat&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your inner function&amp;nbsp;&lt;SPAN&gt;PUT(ABSTRACTION_DATE,8.) converts numeric abstraction_date to a string. The CAT function is a better choice, as it takes both numeric and string numbers and converts to string without errors or warnings regardless of input type.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The problem comes if the string is empty or contains an invalid date. But that can be fixed with a format modifier, that turns invalid or missing dates into missing values without errors or warnings. You you could drop records with missing values later if you want.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have 3 examples, note the ?? as format modifier in 2 and 3:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;123  data _null_;
124      ABSTRACTION_DATE = 20180533;
125      ABSDATE = input(cat(ABSTRACTION_DATE),yymmdd8.);
126      put ABSDATE=;
127  run;

NOTE: Invalid argument to function INPUT at line 125 column 15.
ABSDATE=.
ABSTRACTION_DATE=20180533 ABSDATE=. _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 125:15
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


128
129  data _null_;
130      ABSTRACTION_DATE = 20180530;
131      ABSDATE = input(cat(ABSTRACTION_DATE),??yymmdd8.);
132      put ABSDATE=;
133  run;

ABSDATE=21334
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


134
135  data _null_;
136      ABSTRACTION_DATE = .;
137      ABSDATE = input(cat(ABSTRACTION_DATE),??yymmdd8.);
138      put ABSDATE=;
139  run;

ABSDATE=.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 17:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/533021#M146098</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-02-05T17:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help Converting Numbers to Dates!  PLEASE HELP!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/533023#M146099</link>
      <description>&lt;P&gt;How many observations in your dataset? The error message says it only happened 6 times.&amp;nbsp; If that is 6 out 10,000 observations then it is not such a big deal.&amp;nbsp; If it is 6 out of 6 observations than your data is not like what your code is assuming.&amp;nbsp; Somewhere in between and you might want to see what values are giving it trouble and program around those.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 17:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/533023#M146099</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-05T17:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help Converting Numbers to Dates!  PLEASE HELP!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/533025#M146100</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt;I'm not sure what the problem is. In my calendar, there isn't any day 33, so THIS value:&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;ABSTRACTION_DATE = 201805&lt;U&gt;&lt;FONT color="#FF00FF"&gt;33&lt;/FONT&gt;&lt;/U&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Should and does result in an invalid argument message....because there was not May 33 in 2018. And, it's&amp;nbsp; a NOTE that you need to see because it is telling you that some of your data is invalid -- worth checking out and trying to correct.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 17:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/533025#M146100</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-02-05T17:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help Converting Numbers to Dates!  PLEASE HELP!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/533036#M146103</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We run a data warehouse with about 4000 jobs in our daily batch. Errors that results in return codes are captured by the scheduling environment, but nobody is actually looking through all log files, so notes like "converted to numeric" og "missing values were generated" are not detected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An automated log scan finds jobs with issues that should be corrected, and the common cause is sloppy coding or changes in data, that should be handled. But if the problem is invalid data, and the data source is outside your control, e.g. national data bases, especially old legacy systems with dates entered as free user input maybe 20 years back. you have to live with the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An invalid date will always result in a missing value, so the result will be the same, but if the error cannot be corrected, and you don't want the same job popping up on your alert list every day as "noise", it can be suppressed by ysing the format modifier.&amp;nbsp;I do &lt;U&gt;not&lt;/U&gt; recommend it as a general coding practise, but in some cases it can be very useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 19:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Converting-Numbers-to-Dates-PLEASE-HELP/m-p/533036#M146103</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-02-05T19:11:52Z</dc:date>
    </item>
  </channel>
</rss>

