BookmarkSubscribeRSS Feed
RameshReddy
Calcite | Level 5

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

5 REPLIES 5
Doc_Duke
Rhodochrosite | Level 12

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

RameshReddy
Calcite | Level 5

not clear with your answer ...

Doc_Duke
Rhodochrosite | Level 12

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

art297
Opal | Level 21

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.

TriciaA
Calcite | Level 5

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 5 replies
  • 1567 views
  • 0 likes
  • 4 in conversation