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:
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.