<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to send emails within a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903666#M357065</link>
    <description>&lt;P&gt;Agree it looks like ODS "issue".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fileref in "standard" data step works good:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    data _null_ ;
2      rc=dosubl(
3      'filename fooBar "%sysfunc(pathname(work))/foo.txt" ;
4        data _null_;
5          file fooBar;
6          x = "ABC";
7          put x x x;
8        run;
9        filename fooBar clear ;
10       '
11     ) ;
12   run ;

NOTE: The file FOOBAR is:
      Filename=*****************\foo.txt,
      RECFM=V,LRECL=32767,File Size (bytes)=0,
      Last Modified=17Nov2023:16:01:02,
      Create Time=17Nov2023:16:00:30

NOTE: 1 record was written to the file FOOBAR.
      The minimum record length was 11.
      The maximum record length was 11.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


NOTE: Fileref FOOBAR has been deassigned.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Nov 2023 15:03:08 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2023-11-17T15:03:08Z</dc:date>
    <item>
      <title>How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903488#M356990</link>
      <description>&lt;P&gt;I'm trying to send out custom emails to people on a list and getting the errors:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;ERROR: No logical assign for filename OUTPUTX.&lt;BR /&gt;ERROR: No body file. TAGSETS.MSOFFICE2K(EMAIL) output will not be created.&lt;/P&gt;
&lt;P&gt;The code is:&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;options emailsys=smtp emailhost="exsvr2016.companyname.org";&lt;/DIV&gt;
&lt;DIV&gt;%macro sheets (first, email);&lt;/DIV&gt;
&lt;DIV&gt;data errors_&amp;amp;first;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; set errors (where=(firstname="&amp;amp;first"));&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;FILENAME OUTPUTx EMAIL&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; SUBJECT = "Closeout T "&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; FROM = "&amp;lt;xxx@companyname.org&amp;gt;"&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; TO = "&amp;amp;email"&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; CT ='text/html';&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;ods tagsets.msoffice2k(id=email)&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; file=OUTPUTx&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; style=journal;&lt;/DIV&gt;
&lt;DIV&gt;title1 "Closeout Report: filename.xlsx";&lt;/DIV&gt;
&lt;DIV&gt;title2 "Errors in closed out years";&lt;/DIV&gt;
&lt;DIV&gt;footnote1 "This is an automatically generated email. Please do not respond to this email.";&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; proc report data=error_count (where=(firstname="&amp;amp;first")) nofs;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; columns hospno hospname yob _FREQ_;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; define hospno/"Center" order order=internal display;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; define hospname/"Hospital" display;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; define yob/"Year" display;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; define _FREQ_/"Infants";&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; compute _FREQ_;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; length svar $50;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; if yob=&amp;amp;archiveyr then&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; do;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; svar='style=[backgroundcolor=lightred]';&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; end;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; else do svar='style=[backgroundcolor=white]';&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; end;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; call define (_row_,'style',svar);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; endcomp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; quit;&lt;/DIV&gt;
&lt;DIV&gt;ods tagsets.msoffice2k(id=email) close;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;%mend sheets;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;data _null_;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; set dptlist;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; call symputx ('first', firstname);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; call symputx ('email', email);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; rc=dosubl('%sheets(&amp;amp;first)');&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Where the email is a single email.&lt;BR /&gt;&lt;BR /&gt;This runs fine outside of a macro, but throws the errors once inside of a macro.&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 16 Nov 2023 13:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903488#M356990</guid>
      <dc:creator>kmorrowvt</dc:creator>
      <dc:date>2023-11-16T13:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903510#M356997</link>
      <description>&lt;P&gt;When you get an error message in the log, we need to see the ENTIRE log for this section of code, not just the error messages. Since this is in a macro, you need to run this command first&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then run your code again and copy and paste the log for this section of code into the window that appears when you click on the &amp;lt;/&amp;gt; icon above where you type.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1663012019648.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75161i0E71B1489A6C9839/image-size/large?v=v2&amp;amp;px=999" role="button" title="PaigeMiller_0-1663012019648.png" alt="PaigeMiller_0-1663012019648.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show us the log for this section of code following the above instructions.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 15:08:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903510#M356997</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-16T15:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903514#M356998</link>
      <description>&lt;P&gt;Can you show the code that successfully sent an email BEFORE any macro variables or macro code was used?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 15:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903514#M356998</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-11-16T15:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903520#M356999</link>
      <description>&lt;P&gt;Sorry, this is the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let path=\\burlington.vtoxford.org\corp\stats\;
%include "&amp;amp;path.include\sas_libnames.sas";
options mprint;
data _null;
  year=year(datepart(datetime()));
	month=month(datepart(datetime()));
  call symput ('year', strip(year));
	call symput ('month', strip(month));
run;

%macro years;
%global lastyr clsyr archiveyr nextyr;
%if &amp;amp;month gt 6 %then
  %do;
	  %let lastyr=%eval(&amp;amp;year-1);
		%let clsyr=&amp;amp;year;
	%end;
%else 
  %do;
	  %let lastyear=%eval(&amp;amp;year-2);
		%let clsyr=%eval(&amp;amp;year-1);
  %end;
%let archiveyr=%eval(&amp;amp;year-3);
%let nextyr=%eval(&amp;amp;clsyr+1);
%mend years;
%years;

data center (keep=hospno hospname dptcontact phistartyear);
  set prdcen.tblcenter (where=(dataact=1 and hospno ne 999));
run;
  proc sort data=center;
	  by dptcontact;
	run;
	proc sort data=prdvon.tblLUDPTContact out=contact;
	  by dptcontactid;
	run;
data center;
  merge center (in=a) contact (keep=dptcontactid firstname email rename=(dptcontactid=dptcontact));
	by dptcontact;
	if a;
	drop dptcontact;
	if firstname='Erika P' then firstname='Erika';
run;
data groups (keep=groupid hospno inactivedate);
  set prdcen.tbllnkcentersgroups (where=(groupid=1 and inactivedate ge datetime()));
run;
*Closed Out;
data closeout (keep=hospno closeoutyear ConfirmationRcvd qmrready datafinalized rename=(closeoutyear=yob));
  set prdvon.tblqmrcloseout (where=(&amp;amp;archiveyr le closeoutyear le &amp;amp;clsyr));
run;

	proc sort data=closeout;
	  by hospno yob;
	run;
	proc sort data=center;
	  by hospno;
	run;
	proc sort data=groups;
	  by hospno;
	run;

data errors;
   set prdvon.tblinfanterrors (keep=hospno id byear fieldname errormessage errortype 
                               where=(&amp;amp;archiveyr le yob le &amp;amp;clsyr and errortype in ('E','B'))
															 rename=(byear=yob));
run;
  proc sort data=errors;
	  by hospno yob;
	run;
data errors;
  merge closeout (where=(datafinalized=-1) in=a) errors (in=b);
	by hospno yob;
	if a and b;
run;
data errors;
  merge center errors (in=a) groups (keep=hospno in=b);
	by hospno;
	if a;
	if b then cpqcc=1;
	else cpqcc=0;
run;

  proc sort data=errors;
	  by yob hospno;
	run;
  proc summary data=errors nway;
	  class hospno hospname yob id firstname;
		output out=error_count;
	run;
  proc summary data=error_count nway;
	  class hospno hospname yob firstname;
		output out=error_count;
	run;
	proc sort data=error_count;
	  by yob hospno;
	run;
ods listing close;

options emailsys=smtp emailhost="exsvr2016.burlington.vtoxford.org";
%macro sheets (first, email);
data errors_&amp;amp;first;
  set errors (where=(firstname="&amp;amp;first"));
run;
FILENAME OUTPUTx EMAIL
	SUBJECT = "Closeout T "
	FROM = "&amp;lt;xxx@company.org&amp;gt;"
	TO = "&amp;amp;email"
	CT ='text/html';
ods tagsets.msoffice2k(id=email)
  file=OUTPUTx
  style=journal;
title1 "Closeout Report: file.xlsx";
title2 "Errors in closed out years";
footnote1 "This is an automatically generated email. Please do not respond to this email.";
  proc report data=error_count (where=(firstname="&amp;amp;first")) nofs;
    columns hospno hospname yob _FREQ_;
	  define hospno/"Center" order order=internal display;
		define hospname/"Hospital" display;
	  define yob/"Year" display;
	  define _FREQ_/"Infants";
		compute _FREQ_;
		  length svar $50;
		  if yob=&amp;amp;archiveyr then 
 				do;
			  	svar='style=[backgroundcolor=lightred]';
				end;
			else do svar='style=[backgroundcolor=white]';
				end;
			call define (_row_,'style',svar);
		endcomp;
  run;
  quit;
ods tagsets.msoffice2k(id=email) close; 
%mend sheets;

  proc summary data=errors nway;
	  class firstname email;
		output out=dptlist;
	run; 
data _null_;
  set dptlist;
	call symputx ('first', firstname);
	call symputx ('email', email);
  rc=dosubl('%sheets(&amp;amp;first, &amp;amp;email)');
run;


&lt;/PRE&gt;
&lt;P&gt;And this is the log for the macro call:&lt;/P&gt;
&lt;PRE&gt;1513  data _null_;
1514    set dptlist (where=(firstname='Amy'));
1515    call symputx ('first', firstname);
1516    call symputx ('email', email);
1517    rc=dosubl('%sheets(&amp;amp;first)');
1518  run;

MPRINT(SHEETS):   data errors_Amy;
MPRINT(SHEETS):   set errors (where=(firstname="Amy"));
MPRINT(SHEETS):   run;
NOTE: There were 1100 observations read from the data set WORK.ERRORS.
      WHERE firstname='Amy';
NOTE: The data set WORK.ERRORS_AMY has 1100 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


MPRINT(SHEETS):   FILENAME OUTPUTx EMAIL SUBJECT = "Closeout T " FROM = "&amp;lt;xxx@company.org&amp;gt;" TO =
"xxx@company.org" CT ='text/html';
MPRINT(SHEETS):   ods tagsets.msoffice2k(id=email) file=OUTPUTx style=journal;
NOTE: Writing TAGSETS.MSOFFICE2K(EMAIL) Body file: OUTPUTX
ERROR: No logical assign for filename OUTPUTX.
ERROR: No body file. TAGSETS.MSOFFICE2K(EMAIL) output will not be created.
MPRINT(SHEETS):   title1 "Closeout Report:
file.xlsx";
MPRINT(SHEETS):   title2 "Errors in closed out years";
MPRINT(SHEETS):   footnote1 "This is an automatically generated email. Please do not respond to this
email.";
MPRINT(SHEETS):   proc report data=error_count (where=(firstname="Amy")) nofs;
MPRINT(SHEETS):   columns hospno hospname yob _FREQ_;
MPRINT(SHEETS):   define hospno/"Center" order order=internal display;
MPRINT(SHEETS):   define hospname/"Hospital" display;
MPRINT(SHEETS):   define yob/"Year" display;
MPRINT(SHEETS):   define _FREQ_/"Infants";
MPRINT(SHEETS):   compute _FREQ_;
MPRINT(SHEETS):   length svar $50;
MPRINT(SHEETS):   if yob=2020 then do;
MPRINT(SHEETS):   svar='style=[backgroundcolor=lightred]';
MPRINT(SHEETS):   end;
MPRINT(SHEETS):   else do svar='style=[backgroundcolor=white]';
MPRINT(SHEETS):   end;
MPRINT(SHEETS):   call define (_row_,'style',svar);
MPRINT(SHEETS):   endcomp;
MPRINT(SHEETS):   run;
NOTE: There were 41 observations read from the data set WORK.ERROR_COUNT.
      WHERE firstname='Amy';
NOTE: PROCEDURE REPORT used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds


MPRINT(SHEETS):   quit;
MPRINT(SHEETS):   ods tagsets.msoffice2k(id=email) close;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 1 observations read from the data set WORK.DPTLIST.
      WHERE firstname='Amy';
NOTE: DATA statement used (Total process time):
      real time           0.50 seconds
      cpu time            0.34 seconds
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 22:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903520#M356999</guid>
      <dc:creator>kmorrowvt</dc:creator>
      <dc:date>2023-11-16T22:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903522#M357000</link>
      <description>&lt;P&gt;Added above with the log for the macro portion.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 16:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903522#M357000</guid>
      <dc:creator>kmorrowvt</dc:creator>
      <dc:date>2023-11-16T16:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903573#M357024</link>
      <description>&lt;P&gt;You've got certainly a timing issue in your last data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set dptlist;
	call symputx ('first', firstname);
	call symputx ('email', email);
  rc=dosubl('%sheets(&amp;amp;first)');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Macro variable &amp;amp;first will only be available after the data step (after the run;) and it will contain the value of firstname from the last row of source table dptlist. The same also applies for &amp;amp;email.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't see a macro variable &amp;amp;email used in your macro even though you define it there as an input parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First thing you need to make work is your macro called on it's own.&lt;/P&gt;
&lt;PRE&gt;%sheets (&amp;lt;some value&amp;gt;, &amp;lt;some value&amp;gt;);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once this macro works you can call it dynamically in a data step with code similar to below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set dptlist;
  length cmd $300;
  cmd=cats( '%sheets(',firstname,',',email,');') ;
  call execute(cmd);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 22:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903573#M357024</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-11-16T22:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903575#M357026</link>
      <description>&lt;P&gt;I missed the email in the dosubl, it's been added and it gets used as the "to" in the email.&lt;BR /&gt;&lt;BR /&gt;I don't agree that I have a timing issue. It's grabbing the first name and email row by row and running through the macro as expected.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 22:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903575#M357026</guid>
      <dc:creator>kmorrowvt</dc:creator>
      <dc:date>2023-11-16T22:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903581#M357028</link>
      <description>&lt;P&gt;Does the macro execute as desired if you just call it separately?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10837"&gt;@kmorrowvt&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I don't agree that I have a timing issue. It's grabbing the first name and email row by row and running through the macro as expected.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, you are right. There shouldn't be a timing issue. Tested via below code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(param);
  data _null_;
    put "Value: &amp;amp;param";
  run;
%mend;

data test;
  value='abc'; output;
  value='999'; output;
  value='xyz'; output;
run;

data _null_;
  set test;
  call symputx('mvar',value);
  rc=dosubl('%test(&amp;amp;mvar);');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If it was me then I'd still code as below using call execute().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set test;
  cmd=cats('%test(',value,');');
  call execute(cmd);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In my tests when using call execute() I also get a bit more logging info that shows me better what code the macro actually generates.&lt;/P&gt;
&lt;PRE&gt;NOTE: CALL EXECUTE generated line.
1         + data _null_;     put "Value: abc";   run;

Value: abc&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Nov 2023 23:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903581#M357028</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-11-16T23:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903632#M357051</link>
      <description>&lt;P&gt;Yes, the macro is executing as expected. My only issue is getting it to dynamically send the emails. If I run the filename section outside the macro with the email recipient, the macro runs as expected, but obviously it only sends to the one email address defined outside the macro.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 12:17:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903632#M357051</guid>
      <dc:creator>kmorrowvt</dc:creator>
      <dc:date>2023-11-17T12:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903643#M357059</link>
      <description>&lt;P&gt;What version of SAS do you have?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you call the macro twice (manually, so without DOSUBL or CALL EXECUTE), I assume it works and sends two emails?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For quick fix I would try using CALL EXECUTE instead of DOSUBL.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This part of the log is interesting:&lt;/P&gt;
&lt;PRE&gt;MPRINT(SHEETS):   FILENAME OUTPUTx EMAIL SUBJECT = "Closeout T " FROM = "&amp;lt;xxx@company.org&amp;gt;" TO =
"xxx@company.org" CT ='text/html';
MPRINT(SHEETS):   ods tagsets.msoffice2k(id=email) file=OUTPUTx style=journal;
NOTE: Writing TAGSETS.MSOFFICE2K(EMAIL) Body file: OUTPUTX
ERROR: No logical assign for filename OUTPUTX.
ERROR: No body file. TAGSETS.MSOFFICE2K(EMAIL) output will not be created.&lt;/PRE&gt;
&lt;P&gt;Either the filename statement failed without generating an error message, or there is a weird DOSUBL problem where when you execute the FILENAME statement within the side session it can create a fileref but can't access it, or perhaps tagsets.msoffice2k is not happy writing to it for some reason.&amp;nbsp; It's very odd.&lt;BR /&gt;&lt;BR /&gt;I would try making a much smaller reproducible example to test scenarios, because DOSUBL is interesting magik.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 13:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903643#M357059</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-17T13:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903655#M357063</link>
      <description>&lt;P&gt;Yeah that seems to be it, the timing of compiling with dosubl and it's magic doesn't work, but it does with call execute.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 14:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903655#M357063</guid>
      <dc:creator>kmorrowvt</dc:creator>
      <dc:date>2023-11-17T14:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903661#M357064</link>
      <description>&lt;P&gt;I have played with some small examples, and I have a theory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think when the ODS statement is executed within a DOSUBL block, it can't see a fileref that was created in the side session.&amp;nbsp; It can only see a fileref that exists in the main session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I run:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;
  rc=dosubl(
  'filename foo "%sysfunc(pathname(work))/foo.htm" ; data _null_ ; file foo ; put "hello" ;run ; filename foo clear ;' 
  ) ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;it works.&amp;nbsp; So the filename statement in side session is working, and FILE statement can use the fileref.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if I run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;
  rc=dosubl(
  'filename foo "%sysfunc(pathname(work))/foo.htm" ; ods html file=foo; proc print data=sashelp.class ;run ;ods html close ; filename foo clear ;' 
  ) ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It errors:&lt;/P&gt;
&lt;PRE&gt;162  data _null_ ;
163    rc=dosubl(
164    'filename foo "%sysfunc(pathname(work))/foo.htm" ; ods html file=foo; proc print data=sashelp.class ;run ;ods html close ;
164! filename foo clear ;'
165    ) ;
166  run ;

NOTE: Writing HTML Body file: FOO
ERROR: No logical assign for filename FOO.
ERROR: No body file. HTML output will not be created.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.

NOTE: Fileref FOO has been deassigned.
NOTE: The SAS System stopped processing this step because of errors.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like the fileref is successfully created and cleared, but the fleref exists in the side-session only, not main session.&amp;nbsp; When the ODS statement executes, it's clearly not seeing the side-session fileref.&amp;nbsp; Which explains why if you create the fileref in the main session, the ODS statement works :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename foo "%sysfunc(pathname(work))/foo.htm" ;

data _null_ ;
  rc=dosubl(
  'ods html file=foo; proc print data=sashelp.class ;run ;ods html close ;' 
  ) ;
run ;

filename foo clear ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DOSUBL is actually working really nicely.&amp;nbsp; For example, if you use the FILENAME statement within the DOSUBL side session to clear a fileref that exists in the main session, it will error and tell you it's a scope error :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;136  filename foo "%sysfunc(pathname(work))/foo.htm" ;
137
138  data _null_ ;
139    rc=dosubl(
140    'ods html file=foo; proc print data=sashelp.class ;run ;ods html close ; filename foo clear ;'
141    ) ;
142  run ;

NOTE: Writing HTML Body file: FOO
NOTE: There were 19 observations read from the data set SASHELP.CLASS.

ERROR: Logical name FOO assigned but not in current scope.
ERROR: Error in the FILENAME statement.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's a great error message!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bottom line, I think it's a bug / unwanted behavior of the ODS statement that when run in a DOSUBL side session, it can't see filerefs that exist in the side session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would switch to CALL EXECUTE.&amp;nbsp; Or if you really want to use DOSUBL, you could change your ODS step to send the results to a file, instead of the the fileref.&amp;nbsp; Then you can use a step like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  file outputx; *your filreref point to email;
  infile "...\tempfile.htm"; *temp file with html results;
  input;
  put _infile_;
run;&lt;/PRE&gt;
&lt;P&gt;to send the email.&amp;nbsp; Because this problem seems to be specific to the ODS statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tagging&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp; curious if you agree this looks like a problem with the ODS statement in side-session not being able to see side-session filerefs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 14:45:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903661#M357064</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-17T14:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903666#M357065</link>
      <description>&lt;P&gt;Agree it looks like ODS "issue".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fileref in "standard" data step works good:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    data _null_ ;
2      rc=dosubl(
3      'filename fooBar "%sysfunc(pathname(work))/foo.txt" ;
4        data _null_;
5          file fooBar;
6          x = "ABC";
7          put x x x;
8        run;
9        filename fooBar clear ;
10       '
11     ) ;
12   run ;

NOTE: The file FOOBAR is:
      Filename=*****************\foo.txt,
      RECFM=V,LRECL=32767,File Size (bytes)=0,
      Last Modified=17Nov2023:16:01:02,
      Create Time=17Nov2023:16:00:30

NOTE: 1 record was written to the file FOOBAR.
      The minimum record length was 11.
      The maximum record length was 11.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


NOTE: Fileref FOOBAR has been deassigned.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 15:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903666#M357065</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-17T15:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903668#M357066</link>
      <description>&lt;P&gt;One more example that "it is ODS fault" goes here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    options
2      emailsys=smtp
3      emailhost=("*******************" SSL)
4      emailport = 465
5      emailid="************************"
6      emailpw=XXXXXXXXXXXXXXXXXXXXX
7      emailauthprotocol=PLAIN
8    ;

9    data _null_ ;
10     rc=dosubl(
11     'filename fooBar email
12     "xxx@mail.com"
13      subject="A test"
14     ;
15       data _null_;
16         file fooBar;
17         x = "ABC";
18         put x x x;
19       run;
20       filename fooBar clear ;
21       '
22     ) ;
23   run ;

NOTE: The file FOOBAR is:
      E-Mail Access Device

Message sent
      To:          "xxx@mail.com"
      Cc:
      Bcc:
      Subject:     A test
      Attachments:
NOTE: 1 record was written to the file FOOBAR.
      The minimum record length was 11.
      The maximum record length was 11.
NOTE: DATA statement used (Total process time):
      real time           1.36 seconds
      cpu time            0.07 seconds


NOTE: Fileref FOOBAR has been deassigned.
NOTE: DATA statement used (Total process time):
      real time           1.38 seconds
      cpu time            0.09 seconds

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 15:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903668#M357066</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-17T15:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903669#M357067</link>
      <description>&lt;P&gt;The call execute() is "in the same session" as all ODS references so there is no confusion "where to look for reference".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only thing I would add to the workaround code would be %NRSTR() wrapper, to ensure that 4GL and macro code will run in proper timing:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set test;
  cmd=cats('%NRSTR(%test(',value,'));');
  call execute(cmd);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 15:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903669#M357067</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-17T15:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903672#M357068</link>
      <description>&lt;P&gt;Even SASHELP.VEXTFL view recognise change in filerefs for main[foo1.txt] and DoSubL[foo2.txt] sessions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    filename fooBar "%sysfunc(pathname(work))/foo1.txt" ;
2    data _null_;
3      set sashelp.vextfl;
4      where upcase(fileref)  = "FOOBAR";
5      put xpath=;
6    run;

xpath=R:\_TD23928_YABWONL5P_\foo1.txt
NOTE: There were 1 observations read from the data set SASHELP.VEXTFL.
      WHERE UPCASE(fileref)='FOOBAR';
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


7
8
9    data _null_ ;
10     rc=dosubl(
11     'options ps=min;
12      filename fooBar "%sysfunc(pathname(work))/foo2.txt" ;
13       data _null_;
14         set sashelp.vextfl;
15         where upcase(fileref)  = "FOOBAR";
16         put xpath=;
17       run;
18       '
19     ) ;
20   run ;



xpath=R:\_TD23928_YABWONL5P_\foo2.txt
NOTE: There were 1 observations read from the data set SASHELP.VEXTFL.
      WHERE UPCASE(fileref)='FOOBAR';
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


21
22   data _null_;
23     set sashelp.vextfl;
24     where upcase(fileref)  = "FOOBAR";
25     put xpath=;
26   run;

xpath=R:\_TD23928_YABWONL5P_\foo1.txt
NOTE: There were 1 observations read from the data set SASHELP.VEXTFL.
      WHERE UPCASE(fileref)='FOOBAR';
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 15:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903672#M357068</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-17T15:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903673#M357069</link>
      <description>&lt;P&gt;The pathname() function also recognises reference correctly, what may give some workaround for the issue:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;
  rc=dosubl(
  '
  filename foo "/path/to/some/directory/" ; 

  ods html 
    path="%sysfunc(pathname(foo))"
    file="foo.htm"
    ; 
  proc print data=sashelp.class ;run ;
  ods html close ; 
  filename foo clear ;' 
  ) ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 15:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903673#M357069</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-17T15:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903674#M357070</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;, looking at&amp;nbsp;&lt;SPAN&gt;SASHELP.VEXTFL is really nice.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Everything seems to be working really well in DOSUBL.&amp;nbsp; The side session can see filerefs from the main session, and if you create a side session fileref it will see that one, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It just seems like a problem with ODS statement not being able to see the side-session filerefs.&amp;nbsp; I guess some "part" of the ODS statement is executing in the main session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But as you show, if you can avoid using a fileref on the ODS statement, all is well.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 15:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903674#M357070</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-17T15:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to send emails within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903675#M357071</link>
      <description>&lt;P&gt;One more example (with PDF) now:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    data _null_ ;
2      rc=dosubl(
3      '
4      filename foo "%sysfunc(pathname(work))/foo123.pdf" ;
5
6      ods pdf file="%sysfunc(pathname(foo))"
7        ;
8      proc print data=sashelp.class ;run ;
9      ods pdf close ;
10     filename foo clear ;'
11     ) ;
12   run ;

NOTE: Writing ODS PDF output to DISK destination "R:\_TD23484_YABWONL5P_\foo123.pdf", printer "PDF".
NOTE: This SAS session is using a registry in WORK.  All changes will be lost at the end of this
      session.
NOTE: Writing HTML Body file: sashtml.htm
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.04 seconds
      cpu time            0.04 seconds


NOTE: ODS PDF printed 1 page to R:\_TD23484_YABWONL5P_\foo123.pdf.
NOTE: Fileref FOO has been deassigned.
NOTE: DATA statement used (Total process time):
      real time           0.11 seconds
      cpu time            0.11 seconds


13
14   data _null_ ;
15     rc=dosubl(
16     '
17     filename bar "%sysfunc(pathname(work))/bar123.pdf" ;
18
19     ods pdf file=bar
20       ;
21     proc print data=sashelp.class ;run ;
22     ods pdf close ;
23     filename bar clear ;'
24     ) ;
25   run ;

ERROR: Unable to resolve fileref BAR. ODS PDF initialization fails.
ERROR: Logical name is not available.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: Fileref BAR has been deassigned.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.03 seconds
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 15:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-emails-within-a-macro/m-p/903675#M357071</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-17T15:58:18Z</dc:date>
    </item>
  </channel>
</rss>

