sas - A macro to send a email -


my code send mail using sas data step. here trying create code send mail.

filename outbox email ("***********"); data _null_; file outbox to=("************") from=("***********") subject=("example of sas e-mail" ); /* attach=(""); */ put " "; put "hello boss,"; put " "; put "attached daily operational reports."; put " "; put "rrt"; run; 

i don't tend include email parameters in datastep itself, rather in fileref. have tested code below email address , worked.

as said in comments, need wrap datastep in macro if want run within macro.

you can have positional or keyword parameters. see source detailed info. have used keyword parameters in example. call macro specifying keyword , value showed last line. if don't put anything, keyword gets ignored.

by way, empty keywords result in initialised local macro variables. let statements ( %let from=from="&from") there add string "from=" beginning of "from" macro variable filename syntax complete. if macro variable such "from" passed is, resolve email address filename woudn't know with.

   %macro send_email (to=,from=,subject=,attachment=,body=);     %if &to ne %then         %let to="&to";      %if &from ne %then         %let from=from="&from";      %if &subject ne %then         %let subject=subject="&subject";      %if &attachment ne %then         %let attachment=attachment="&attachment";      %if &body ne %then         %let body="&body";     filename outbox email &to &from &subject &attachment;      data _null_;         file outbox;         put &body;     run;  %mend;  %send_email(email=example@example.com); 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -