Hi Folks:
I imported a data.csv using 'proc import'. The data had two date variables: 'confirmed_date' and 'deceased_date'. Before importing, both appeared to have a format 'Date' in the CSV as shown in the screenshot below. However, one of the dates 'deceased_date' was broke in the resulting SAS dataset after imported.
What happened to cause that 'deceased_date' was broke but not 'confirmed_date' ?
Any pointers that could be corrected in my 'proc import' code below?
Thanks for your time in advance.
proc import
datafile="...\patientinfo.csv"
out=patientinfo
dbms=csv replace;
getnames=yes;
run;
Check the log and see that field is set to be read as a character. My guess is somewhere in the first 1000 rows you have a lot of missing data so it assumed it was a character and imported it as such. Add GUESSINGROWS=MAX; , which will take a long time is one try to fix it. If that works, I would recommend you take the code from the log and use that for future imports - it's much faster than when SAS has to guess each type.
In general, it's bad practice to use PROC IMPORT to rely on for data imports, you should be building your data import of a specification list or data dictionary.
Check the log and see that field is set to be read as a character. My guess is somewhere in the first 1000 rows you have a lot of missing data so it assumed it was a character and imported it as such. Add GUESSINGROWS=MAX; , which will take a long time is one try to fix it. If that works, I would recommend you take the code from the log and use that for future imports - it's much faster than when SAS has to guess each type.
In general, it's bad practice to use PROC IMPORT to rely on for data imports, you should be building your data import of a specification list or data dictionary.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: