BookmarkSubscribeRSS Feed
SASAlex101
Quartz | Level 8

I have a dataset in SAS saved called SET1

 

I'm building a SAS job that will run daily and intake an excel file to be appended to the saved table. The excel files come in daily and are different file names. My code already will pick up any new file that comes in. I want to manage errors in this process. My main concern is SAS EG may pick a different data type from any given excel import as a default which may or may not match the SET1 Data type for the same column. I also want to guard against missing columns as well. 

 

1. Is there something for proc import that will automatically tell SAS "if the data type of the import column doesn't match, then convert it to the data type of SET1  for each same column name"? 

 

2. Also if the import column name is not in SET1 then do not import. Apply a NULL to any missing column in SET1. 

 

Thanks; 

 

1 REPLY 1
Reeza
Super User

For Excel files, those are data quality processes you need to build in manually unfortunately.

If the file was a text file, then SAS would generate errors with a data step if the types did not match.

 

EDIT: you can use PROC COMPARE to compare your inputted data to your master table. It identifies mismatches and such. 

I find that never quite works the way I want to, so end up rolling my own essentially. You can use the SAS dictionary tables to help support that though.

Something like this could be expanded to check types and such. 

https://gist.github.com/statgeek/3b57ae085d9f7a36a2d95c15f04e72e6

 

Also, use APPEND to combine the data sets so that it enforces the main table structure, then anything else will usually generate an error.

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 193 views
  • 0 likes
  • 2 in conversation