Help using Base SAS procedures

ERROR HANDLING

Reply
New Contributor
Posts: 2

ERROR HANDLING

Hi,

I am trying to make a SAS JOB fail. I need a way to make a job fail if the last table has no columns. How can I do this? I made a user transform with one input and no output, I can count the rows, but can't find a way to make an error of it.That is I can make an error but it happens even when there are multiple rows in the table. I used ABORT way to stop it, but this does not generate an error. But the user tranform wont let me use my macro for sending mail in this case. So then I need an error as this generates an error mail.

Hope someone knows.

-Daniel
Super Contributor
Super Contributor
Posts: 3,174

Re: ERROR HANDLING

SAS version? OS where SAS JOB is running? This information makes a difference and is important with each SAS forum post.

And please...share your code that is not working for you to get useful feedback.

Scott Barry
SBBWorks, Inc.
New Contributor
Posts: 2

Re: ERROR HANDLING

This is for DI Studio 3.4 (metaserver 9.1.3.4)

I do not have much code as I do not get it to work, but here is what I start with;

%LET dsid=%SYSFUNC(OPEN(&syslast.));
%LET n=%SYSFUNC(ATTRN(&dsid,NOBS));
%LET rc=%SYSFUNC(CLOSE(&dsid));

This gives me number of records in last table, so if &n. < 1 then I want the job to go to error. This is all suposed to happend in a user transform.

Any idea?

-Daniel
Regular Contributor
Posts: 191

Re: ERROR HANDLING

abort abend???
Super Contributor
Super Contributor
Posts: 3,174

Re: ERROR HANDLING

To start, you are working with the SAS macro language. So you will need to consider coding a SAS macro with %IF %THEN %DO %END (possibly) and use the %ABORT statement. Or as was mentioned, conditionally execute a SAS DATA step to generate a more meaningful output message to the SAS log and then execute an ABORT ABEND statement.

Also, in addition to the recommended DOC reading below, you may find additional info in the SAS companion guide for your Operating System, where ABORT is further discussed for your OS.

Scott Barry
SBBWorks, Inc.

SAS Macro Language - %ABORT Statement
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002475061.htm

SAS Language Dictionary - ABORT statement
http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000230210.htm
Ask a Question
Discussion stats
  • 4 replies
  • 187 views
  • 0 likes
  • 3 in conversation