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: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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