One thing that helps greatly on the path to better coding is adapting a solid, consistent, visual coding style that makes code easier to read and identify logical units.
Consider these slight changes to your original code:
%macro data_check;
data _null_;
trading_dt = today() - 2;
filedate = put(trading_dt,yymmddn8.);
put trading_dt date9.;
put filedate;
call symput('trading_dt',trading_dt);
call symput('filedate',filedate);
run;
proc sql noprint;
select
count(*) into :cnt
from WORK.WET_REP_TXN
;
quit;
%if &cnt ne 0 %then %do;
ods tagsets.excelxp file='\\10.64.23.39\Users\88094701\WET_REP_txn.xml' style=minimal;
proc print data=WET_REP_TXN noobs;
run;
ods tagsets.excelxp close;
filename alert email
from=("to_me@hotmail.com")
to=("to_me@hotmail.com")
subject = "Generated - storage.customer &filedate "
attach=("\\10.64.23.39\Users\88094701\WET_REP_txn.xml" content_type="application/vnd.ms-excel")
;
data _null_;
file alert;
put "storage.customer is ready";
run;
%end;
%mend;
%data_check;
The details of such coding style are up to you (how many columns used for each indentation etc), but visually pleasing code makes for faster working and easier detection of logical/semantic mistakes.
Keep in mind that someone has to make sense of your code someday, and most of the time that someone will be you, so be good to your future self!
... View more