BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cruise
Ammonite | Level 13

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;

import problem.png

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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. 

 

 

View solution in original post

2 REPLIES 2
Reeza
Super User

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. 

 

 

Cruise
Ammonite | Level 13
GUESSINGROWS=MAX; Fixed the problem. Yes. The date variable broke had missing for about 98% of the data.
Thank you very much Reeza. I greatly appreciate it.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 635 views
  • 1 like
  • 2 in conversation