10-10-2016 12:45 PM - edited 10-11-2016 04:41 PM
I am trying to read a date column in sas from csv file but it gives some error:
error: NOTE: Invalid argument to function INPUT at line 2134 column 11
Appreciate any help to resolve this issue. Thanks
format date date9.;
if not missing(date) then do;
10-10-2016 01:44 PM
10-10-2016 04:58 PM
SAS offers generic date formats such as ANYDTDTE. to handle this kind of poor quality data. Try:
data have; input id date :$20.; datalines; 1 27-Apr-12 2 03APR2013 3 11-Mar-13 4 01-Jun-12 ; data want; set have; d = input(date, ?? anydtdte.); format d yymmdd10.; drop date; rename d=date; run; proc print; run;
10-11-2016 04:53 AM
Simple answer, clean your data. 27-Apr-12 is not the same as 27APR2012 or in fact 20120427. What if you have dates in US format:
02012012 - is this 02Jan or 01Feb? Garbage data will 90% of the time yield garbage results.
And a secondary note, CSV is not Excel, CSV=Comam Separated Variable file, which is a plain text file with commas separating data elements. The fact that Excel has a parser for that doesn't make it an Excel file.