Desktop productivity for business analysts and programmers

Syserror not resolving

Reply
Contributor
Posts: 31

Syserror not resolving

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

Trusted Advisor
Posts: 2,114

Syserror not resolving

Check the manual for SYSERR, "SYSERR automatic macro variable is reset at eachstep boundary."  The SQL procedure ran.

Contributor
Posts: 31

Syserror not resolving

not clear with your answer ...

Trusted Advisor
Posts: 2,114

Syserror not resolving

&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.

PROC Star
Posts: 7,437

Syserror not resolving

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.

Contributor
Posts: 40

Syserror not resolving

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;

Ask a Question
Discussion stats
  • 5 replies
  • 251 views
  • 0 likes
  • 4 in conversation