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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.