Hi all,
what can i put in the %abend part of the program to safely stop code execution . I do not want any further steps to be executed
*---------------------------------------------------------------------------------------------------------------*
%macro Check(file_upload_date.)
proc sql;
create table t1 as
select max(Response_File_Load_Date) as max_File_Load_Date format=date9.
into :max_File_Load_Date
from My_lib.Table1
/* where dt < today() and flg = 0*/
;quit;
%put &max_File_Load_Date.;
%if &max_File_Load_Date. >= &file_upload_date. %then %abend;
%mend;
%check(&file_upload_date.);
you can try like below
%macro Check(file_upload_date.)
proc sql;
create table t1 as
select max(Response_File_Load_Date) as max_File_Load_Date format=date9.
into :max_File_Load_Date
from My_lib.Table1
/* where dt < today() and flg = 0*/
;quit;
%put &max_File_Load_Date.;
%if &max_File_Load_Date. >= &file_upload_date. %then %do;
%abort;
%end;
%mend;
%check(&file_upload_date.);
you can try like below
%macro Check(file_upload_date.)
proc sql;
create table t1 as
select max(Response_File_Load_Date) as max_File_Load_Date format=date9.
into :max_File_Load_Date
from My_lib.Table1
/* where dt < today() and flg = 0*/
;quit;
%put &max_File_Load_Date.;
%if &max_File_Load_Date. >= &file_upload_date. %then %do;
%abort;
%end;
%mend;
%check(&file_upload_date.);
First of all, you need to make sure that your code works at all. Maxim 2: Read the Log:
ERROR: Symbolic variable name FILE_UPLOAD_DATE. must contain only letters, digits, and underscores. ERROR: Invalid macro parameter name FILE_UPLOAD_DATE.. It should be a valid SAS identifier no longer than 32 characters. ERROR: A dummy macro will be compiled. 72 73 %macro Check(file_upload_date.) 74 proc sql; 75 create table t1 as 76 select max(Response_File_Load_Date) as max_File_Load_Date format=date9. 77 into :max_File_Load_Date 78 from My_lib.Table1 79 /* where dt < today() and flg = 0*/ 80 ;quit; 81 %put &max_File_Load_Date.; 82 %if &max_File_Load_Date. >= &file_upload_date. %then %abend; ERROR: Macro keyword ABEND is not yet implemented. 83 %mend;
First fix the issue with the invalid macro parameter name.
Then use a %put statement instead of the (invalid) %abend statement. Testing that will reveal that your comparison will not work as intended because you formatted the macro variable max_File_Load_Date with DATE9.; 01MAY2020 is "smaller" than 30APR2020 in a text comparison. Maxim 28: Macro Variables Need No Formats. The raw numeric values will always work correctly.
Follow Maxim 1 (Read the Documentation) to find out how to abort a SAS session with a macro statement:
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.