Chapter Contents

Previous

Next
SAS Companion for the Microsoft Windows Environment

Getting Feedback from the SAS Session

The SAS System provides two properties, RC and ResultString, that make it possible to pass information from the SAS session that you are automating back to the application that is controlling it. RC can contain a number; ResultString can contain a text string.

To set the values of these properties from within the SAS session, use the SETRC function with this syntax:

error=SETRC("result-string", rc-number);
where result-string is the value to be assigned the ResultString property, and rc-number is the value to be assigned to the RC property.

For example, you can use the Submit method to submit DATA step code that returns an error code as part of its processing. You can then check the value of that error using the RC or ResultString property. Here is a Visual Basic example of this:

Dim OleSAS as Object
Set OleSAS = CreateObject("SAS.Application")
OleSAS.Wait = True
OleSAS.Submit("data _null_; 
       error=setrc('Error string', 2.0); 
       put error; run;")
If (OleSAS.RC <> 0) Then
    Response = MsgBox(OleSAS.ResultString, 
               vbOKOnly, "Error message is", 
               0, 0)
EndIf
Note that the Wait property is set to True in this example. This ensures that the DATA step finishes processing before the automation controller checks the value of the RC property.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.