Hi,
I am using PROC SQL to perform some insert records using SAS - TERADATA.
I didn't use library reference(to connect with database) prior to the PROC SQL step so the code was error out which is expected.
ERROR: Libname TERADATA is not assigned.
After PROC SQL step, I am printing &SQLXRC to check error code so based on that I am printing messages.
%put SQL Error Code : &sqlxrc.;
%if &sqlrc. eq 0 %then %do;
data _null_;
put "Job has been Completed";
run;
%end;
%else %do;
data _null_;
put "Job end with error";
%end;
The issue is, code was ended with error but still &SQLXRC resolves to 0 and the message shows job has been completed. I am not sure, What I'm missing here ? Can someone help me to resolve this issue.
The doc states: SQLXRC contains DBMS specific error codes.
The error here is a SAS error. No database code was executed, so there is no DBMS error and the macro variable kept its default value of 0.
You can also use variables SQLRC for proc sql errors, SYSRC for OS errors, and SYSERR for SAS errors.
The doc states: SQLXRC contains DBMS specific error codes.
The error here is a SAS error. No database code was executed, so there is no DBMS error and the macro variable kept its default value of 0.
You can also use variables SQLRC for proc sql errors, SYSRC for OS errors, and SYSERR for SAS errors.
It work's now, thanks Chris
Which macro variable are you trying to access SQLXRC or SQLRC?
If you want the value of SQLXRC make sure to save it into your own macro variable before running any other SQL commands that access the a remote database since it is reset after each statement.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.