When you change the DATESTYLE= option to DMY to read date fields correctly and you set the value of USEDATESTYLE=YES (which is needed in order for the DATESTYLE= option to be honored), a quoted string is read as a date and not a character field.
For example, the following sample data causes the issue:
range,startdt,amt,amt2,startdt2
"21-27",12-12-22,12345.5,22345.5,12/12/2022
Here is the PROC IMPORT code:
options datestyle="dmy";
proc import datafile='c:\temp\sample.csv' out=sample dbms=csv replace;
run;
After you set the USEDATESTYLE= to YES in the SAS Registry, as shown in the image below, the issue occurs:
The RANGE variable is read as a SAS date using the DDMMYYw. Informat instead of a character variable using the $w. Informat. As a result, an invalid data message similar to the following occurs in the SAS log:
NOTE: Invalid data for range in line 2 1-5.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---
2 "21-27",12-12-22,12345.5,22345.5,12/12/2022 43
range=. startdt=12/12/22 amt=12345.5 amt2=22345.5 startdt2=12/12/2022 _ERROR_=1 _N_=1
Workaround
If you use the IMPORT procedure in SAS to read an external file, complete one of the following workarounds to circumvent the issue: