Getting Feedback from the SAS Session

SAS 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:
Private Delcare Sub Sleep Lib “kernel32” (ByVal dwMilliseconds As Long)

Private Sub Command1_Click()
Dim OleSAS as Object
Set OleSAS = CreateObject("SAS.Application")
OleSAS.Submit("data _null_; 
       error=setrc('Error string', 2.0); 
       put error; run;")
Sleep 500
Do while x=0
  If (OleSAS.Busy) then
     Sleep 500
  else
     If (OleSAS.RC <> 0) Then
         Response = MsgBox(OleSAS.ResultString, 
               vbOKOnly, "Error message is", 
               0, 0)
   x=1
EndIf
Loop
End Sub