johankw
johankw

Reputation: 1

proc import CSV SAS empty values date

I need to import a CSV file in SAS and it gets stuck on empty fields with a date format. My log shows this field is properly recognised as DATETIME. and ANYDTDTM40. just like other datetime fields. In The first records this field is empty and the LOG then gives a NOTE invalid data. When I enter a date in the first rows with empty fields the message moves along. So it clearly has to do with missing values. Can someone help me out?

Upvotes: 0

Views: 1067

Answers (1)

Reeza
Reeza

Reputation: 21264

In the future please make sure to show your actual code and the log - feel free to omit the data part of the log if it's confidential information.

PROC IMPORT is a guessing procedure and guesses at types. For production processes it's not a good idea to use PROC IMPORT.

You can add the GUESSINGROWS=MAX; option to your code to force SAS to scan the entire file before guessing at types. This will increase the run time of the process but will likely fix your issue. Also, ensure your datetime fields are consistent and correct. If the data does has mixed date types, ie MMDDYY and DDMMYY then it can be bit of a pain to manage. Or if it has DDMMYY and SAS guesses MMDDYY (or vice versa) you'll get a bunch of errors. In that case you need to write your own data step code to read in the data. You can use the code from the log as a starting point.

Upvotes: 1

Related Questions