BookmarkSubscribeRSS Feed
SureshKasturi
Calcite | Level 5

Hi everyone,

How to clear syserrortext macro vaiable?

data se%;

test = "&syserrortext";

run;

DATA SE%;

      
              22
              200

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_. 

ERROR 200-322: The symbol is not recognized and will be ignored.

this is correct for resolving macro,

data  clear;

sett="&syserrortext ";

run;

proc sql;

select count(*)  into : error from clear;

run;

%macro test;

%if &error >0 %then %do;

data test;

set sashelp.class;

run;

%end;

%else %if &error=0 %then %do;

Successfully Generated;

%end;

%mend;

%test;

here , syserrortext affecting second program

data set;

set sashelp.class;

run;

data  clear12;

sett="&syserrortext ";

run;

proc sql;

select count(*)  into : error from clear;

run;

%macro test;

%if &error >0 %then %do;

data test;

set sashelp.class;

run;

%end;

%else %if &error=0 %then %do;

Successfully Generated;

%end;

%mend;

%test;

please help me, to clear syserortext macrovaribale.

Thanks in advance

1 REPLY 1
RichardDeVen
Barite | Level 11

Automatic macro variable SYSERRORTEXT is a read-only variable.  The only way I have found to reset SYSERRORTEXT to blank is to log a blank error message. Not super useful because of the extra ERROR: line in the log file.

 

Also, SYSERRORTEXT captures only the last ERROR: line logged.

 

Example:

 

options nosource;
libname xyz abc "123"; %put &=SYSERRORTEXT; %if %length(&SYSERRORTEXT) %then %do; %put ERROR: %str( ); %end; %put &=SYSERRORTEXT;

will log

ERROR: The ABC engine cannot be found.
ERROR: Error in the LIBNAME statement.
SYSERRORTEXT=Error in the LIBNAME statement.
ERROR:
SYSERRORTEXT=

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
  • 1 reply
  • 2529 views
  • 2 likes
  • 2 in conversation