Search code examples
sassas-macro

Using SAS and Linux to send email with reference to macro


I am trying to send an email using SAS from within Linux, In the body of the email I have a reference to a macro.

* store &a in macro for use in email; 
proc sql noprint;
    select tot_sendt into :a from tot;
run;


* sending email;
filename m email subject="Report A is ready (%SYSFUNC(today(),ddmmyy10.))"
to = ('myemail@email.com');

data _null_;
  file m;
  put 'Report A ready;
  put 'Totalt sent is:' &a; *a is a number stored in a macro;
run;

However, this code throws the following error: test_pgm.log.140825.1227:ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase. test_pgm.log.140825.1227:ERROR 557-185: Variable set is not an object.

I have also tried

  put 'Totalt sent is &a'; a is a number stored in a macro

Which just writes &a in to email body.


Solution

  • Macro variables won't resolve inside of single quotes.

    put "Totalt sent is &a" ;
    

    should work.

    Also note you are missing the closing single quote on your first PUT statement.