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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -