BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AshokD
Obsidian | Level 7

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

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.

View solution in original post

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

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.

AshokD
Obsidian | Level 7

It work's now, thanks Chris

Tom
Super User Tom
Super User

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1224 views
  • 1 like
  • 3 in conversation