DATA Step, Macro, Functions and more

Trapping bad data from EXCEL

Reply
N/A
Posts: 0

Trapping bad data from EXCEL

We have a batch process that imports a large number of EXCEL workbooks.
Sometimes a field which ought to be numeric contains character data.
This error stops the entire process.
We would like to be able to note/trap the error and continue importing the rest of the workbooks.

How can we achieve this?

Thanks in Advance
Super Contributor
Super Contributor
Posts: 3,174

Re: Trapping bad data from EXCEL

Posted in reply to deleted_user
Are you using SAS PROC IMPORT or are you using some DATA step or another technique to "import" your data to SAS? You can always use INFILE/INPUT processing, input the field as CHARACTER, test it using an ANYxxxxx type function and execute accordingly as you prescribe in your program.

Scott Barry
SBBWorks, Inc.
PROC Star
Posts: 1,760

Re: Trapping bad data from EXCEL

Posted in reply to deleted_user
As Scott says, the usual way to do this is to
- read values into temp character variables,
- test the validity of the values,
- convert to numeric and drop temp character variables,
- save.
Super Contributor
Posts: 359

Re: Trapping bad data from EXCEL

Posted in reply to deleted_user
You need to code error handling routines to trap and reset error codes to let your process continue. I found several papers that my help you for instance
http://www.nesug.org/proceedings/nesug05/ap/ap9.pdf

Google "error handling sas"
Ask a Question
Discussion stats
  • 3 replies
  • 274 views
  • 0 likes
  • 4 in conversation