I already have a long SAS code that will extract transform and analyze the data. I want to build in some checks for the data in the middle of the program. Ideally, if the check fails, the rest of the code should stop executing so user can review, edit and restart the program where the code stopped. I tried to use %abort to stop the program, but it only stops the macro and the rest of the program still executes. I tried to use %abort abend and %abort return, it stopped executing the rest of the program but also closed SAS (which I do not want). The documentation for %abort abend and %abort return says: "further action is based on how your operating environment and your site treat jobs that end abnormally". Can anyone help determine a method to either update my "environment" so SAS is not closed when the "jobs end abnormally" or an alternative method to achieve my desired results. Please do not propose any solutions that requires the rest of the program to be put in a conditional statement as the program combined with multiple instances of this check will make the program unwieldy for future edits. Please see code I used to test abort feature below: data test_data;
j = 1;
do i = 1 to 10;
output;
end;
run;
%macro test_for_duplicates (input_dataset, primary_key);
proc sort data = &input_dataset dupout = duplicate_records nodupkey;
by &primary_key;
run;
proc sql noprint;
select count(*) into: dup_obs_count from duplicate_records;
quit;
%if &dup_obs_count. > 0 %then %do;
%put "error message here";
%abort;
%end;
%mend;
%test_for_duplicates(test_data, j);
%put "rest of program here"; Thanks.
... View more