Use a DATA step to set your exit code.
*************************check from here******************************;
data _null_;
status = 0;
IF &TOPRC02=&TDETAIL=&TODETAIL=&TOBILLER THEN status=20 ;
else IF &TOPRC03=&TDETAIL=&TODETAIL=&TOBILLER THEN status=30;
else IF &TOPRC04=&TDETAIL=&TODETAIL=&TOBILLER THEN status=40;
else IF &TOPRC05=&TDETAIL=&TODETAIL=&TOBILLER THEN status=50;
else IF &TOPRC06=&TDETAIL=&TODETAIL=&TOBILLER THEN status=60;
else IF &TOPRC07=&TDETAIL=&TODETAIL=&TOBILLER THEN status=70;
else IF &TOPRC08=&TDETAIL=&TODETAIL=&TOBILLER THEN status=80;
if status then abort return status ;
run;
If you want to get the SUM() of a value and use in a later data step then perhaps you want something like this:
proc summary nway data=have ;
var MYVAR ;
output out=sum_myvar sum=sum_myvar ;
run;
data want ;
if _n_=1 then set sum_myvar ;
set have ;
if myvar > sum_myvar/2 then put 'This value accounts for more than half of the total' (_all_) (=);
run;
While you already have a post that identifies the cause of the problem, you would be well advised to combine all of this code into a much simpler form:
proc sql;
select sum(QDW_USD_AMT) into : check from TDTL;
quit;
This creates the macro variable directly (but doesn't give you an output data set and doesn't perform the renaming piece).
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.