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:
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.