hi,
I am trying to execute below mentioned code , syserror is resolving always ZERO ,if any error occurs still its resolving 0 , any one can tell what"s wrong on this code
%macro test;
proc print data=sashelp.clss;
run;
proc sql noprint;
select Count(*) into :CONT from sashelp.class;
quit;
options symbolgen ;
%put &SYSERR;
%if (&cont = 0 and &syserr=0) or (&cont = 0 and &syserr > 0) or
(&cont > 0 and &syserr > 0)
%then %do ;
%let V_STATUS=0;
%end;
%else;
%IF &cont > 0 and &syserr=0 %THEN %do ;
%let V_STATUS=1;
%end;
%mend;
%test;
Regards,
Ramesh
Check the manual for SYSERR, "SYSERR automatic macro variable is reset at eachstep boundary." The SQL procedure ran.
not clear with your answer ...
&syserr is set to 3000 by the failing PROC PRINT, but it is reset to 0 by the successful PROC SQL, so it is always 0 when it gets to your %IF statements.
Put the OPTIONS SYMBOLGEN; at the top to see what is going on.
What are you trying to find out? Doc already explained about syserr and it being set to 3000 because of the sashelp.clss file doesn't exist, but what are you expecting?
Your v_status macro variable won't resolve after the macro as it is a local rather than global macro variable.
Run this code and it will be more clear what is happening: The bold line is especially important.
%macro test;
title "This is my test";
proc print data=sashelp.clas;
run;
%put SYSERR is this value: &syserr.;
proc sql noprint;
select Count(*) into :CONT from sashelp.class;
quit;
%put SYSERR is this value: &syserr.;
%put CONT is this value: &cont.;
%if (&cont = 0 and &syserr=0)
or (&cont = 0 and &syserr > 0)
or (&cont > 0 and &syserr > 0)
%then %do ;
%let V_STATUS=0;
%end;
%else;
%IF &cont > 0 and &syserr=0 %THEN %do ;
%let V_STATUS=1;
%end;
%put V_STATUS is this value: &V_STATUS.;
%mend;
%test;
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.