I am trying to import a csv file using the code below, however, for the date column SAS is giving me the NOTE: Invalid data for Date in line 2 40-48. And it also says DOB=. _ERROR_=1 _N_=1
data BH;
infile 'C:\desktop\NewDemo\apeal2.csv' dsd firstobs=2 truncover;
length ID 8 Race $32. Ethnicity $32 Gender $20;
input ID Race Ethnicity Gender Date;
format Date date9.;
run;
Add a delimiter to the INFILE statement, and the proper informat:
data BH;
infile
'C:\desktop\NewDemo\apeal2.csv'
dlm=','
dsd
firstobs=2
truncover
;
length ID 8 RACE $32 ETHNICITY $40 Gender $20 date 4;
input ID RACE ETHNICITY Gender Date :mmddyy10.;
format Date mmddyy10.;
run;
There is no variable DOB in the code you posted, so the log message cannot be from that step.
Please post the complete log from the failing step; use this button to post the log:
Add a delimiter to the INFILE statement, and the proper informat:
data BH;
infile
'C:\desktop\NewDemo\apeal2.csv'
dlm=','
dsd
firstobs=2
truncover
;
length ID 8 RACE $32 ETHNICITY $40 Gender $20 date 4;
input ID RACE ETHNICITY Gender Date :mmddyy10.;
format Date mmddyy10.;
run;
You did not assigned informat for the input date.
Please post:
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.