<?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: Write fields of a table to the body of an Email in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947965#M45419</link>
    <description>&lt;P&gt;Thanks for the tip!&amp;nbsp; Question:&amp;nbsp; I am still fairly new, when you said there's a PDF file, how do i find that?&amp;nbsp; I went to the Webinar you linked, but I'm not sure where i can find the file.&amp;nbsp; Much appreciate your help!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rebecca_K_0-1729196533724.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101421i1D1771244369DEC7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rebecca_K_0-1729196533724.png" alt="Rebecca_K_0-1729196533724.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Oct 2024 20:22:56 GMT</pubDate>
    <dc:creator>Rebecca_K</dc:creator>
    <dc:date>2024-10-17T20:22:56Z</dc:date>
    <item>
      <title>Write fields of a table to the body of an Email</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947736#M45408</link>
      <description>&lt;P&gt;Hello!&amp;nbsp; I'd like to write the contents of a table to an email, any ideas how to go about this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what I have so far.&amp;nbsp; In the section that reads "PUT RESULTS HERE" I'd like to write:&lt;/P&gt;&lt;P&gt;Member:&amp;nbsp;12345678901&amp;nbsp;&amp;nbsp;&amp;nbsp;Amount: 10&lt;BR /&gt;Member:&amp;nbsp;1234567892&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Amount:&amp;nbsp;6&lt;BR /&gt;Member: 1234567893 Amount:&amp;nbsp;5&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;DATA WANT;
INPUT MEMBER : $20. AMOUNT : 8. ;
CARDS;
1234567891 10 
1234567892 6
1234567893 5
1122334455 4
;
run;&lt;/CODE&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;filename outmail email 
	to=&amp;amp;toEmail. 
	from=&amp;amp;fromEmail. 

	subject="Results are in";

	data _null_;
	file outmail;
	put Here are the results:  ;
/* PUT RESULTS HERE */

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2024 18:45:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947736#M45408</guid>
      <dc:creator>Rebecca_K</dc:creator>
      <dc:date>2024-10-16T18:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Write fields of a table to the body of an Email</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947859#M45409</link>
      <description>&lt;P&gt;Have a look at&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Ask-the-Expert/Tips-and-Tricks-for-Sending-Emails-Using-SAS-Q-amp-A-Slides-and/ta-p/767376" target="_blank"&gt;Tips and Tricks for Sending Emails Using SAS: Q&amp;amp;A, Slides, and On-Demand Webinar&lt;/A&gt;&amp;nbsp;- there are several great options and examples provided there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 13:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947859#M45409</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-10-17T13:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Write fields of a table to the body of an Email</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947872#M45410</link>
      <description>&lt;P&gt;Hi, thanks for the reply.&amp;nbsp; &amp;nbsp;I skimmed through the hour long webinar you suggested, and see that you can write a proc report to an email.&amp;nbsp; I tried to keep it basic to start.&amp;nbsp; Email was sent, but the data from the table did not write.&amp;nbsp; Am I missing something?&amp;nbsp; Here is the code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;filename outmail email 
	to=&amp;amp;toEmail. 
	from=&amp;amp;fromEmail. 

	subject="Results are in";

	data _null_;
	file outmail;
	put "Here are the results:  ";

/* NEW CODE HERE: */
   proc Report data=Want;
   run;


run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Oct 2024 14:32:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947872#M45410</guid>
      <dc:creator>Rebecca_K</dc:creator>
      <dc:date>2024-10-17T14:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Write fields of a table to the body of an Email</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947956#M45418</link>
      <description>&lt;P&gt;Yes - see pages 10 and 11 of the handout (PDF). The idea is to use ODS to capture the PROC output and write it to your email file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename &lt;STRONG&gt;mail&lt;/STRONG&gt; email ... ;
ods html(id=email) file=&lt;STRONG&gt;mail&lt;/STRONG&gt; style=daisy;
/* PROC output here */
ods html(id=email) close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Oct 2024 20:13:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947956#M45418</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-10-17T20:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Write fields of a table to the body of an Email</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947965#M45419</link>
      <description>&lt;P&gt;Thanks for the tip!&amp;nbsp; Question:&amp;nbsp; I am still fairly new, when you said there's a PDF file, how do i find that?&amp;nbsp; I went to the Webinar you linked, but I'm not sure where i can find the file.&amp;nbsp; Much appreciate your help!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rebecca_K_0-1729196533724.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101421i1D1771244369DEC7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rebecca_K_0-1729196533724.png" alt="Rebecca_K_0-1729196533724.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 20:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947965#M45419</guid>
      <dc:creator>Rebecca_K</dc:creator>
      <dc:date>2024-10-17T20:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Write fields of a table to the body of an Email</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947974#M45420</link>
      <description>&lt;P&gt;Are you sending one email with all 6 of those data points?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out email ....... ;
data _null_;
  file out;
  set want ;
  put member= amount=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or are you sending separate emails to each of the members? In which case where are you going to find the email address of where to send it?&amp;nbsp; If you have the address in the dataset then just use &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hostunx/p1hl3t66coao7bn18vrmhx2gte1q.htm#p03zfi6s5c36sln0z31g5hwdna3c" target="_self"&gt;EMAIL DIRECTIVES&lt;/A&gt; in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's adapt their example to your example. So try something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input MEMBER :$20. AMOUNT EMAIL $40. ;
CARDS;
1234567891 10 team1@x.com
1234567892 6  team2@y.com
1234567893 5  team3@z.com
1122334455 4  team3@z.com
;

filename reports email 'Member amount';

data _null_;
  file reports;
  set have ;
  by email ;
  if first.email then do; 
* Set email attributes and write header of report ;
    put '!EM_NEWMSG!';                    
    put '!EM_TO!' email;
    put '!EM_SUBJECT! Report for ' email;  
    put 'Here is the latest report for ' email '.';
  end;
* send the data message ;
    put member= amount= ;

  if last.email then do;
* send the message ;
    put '!EM_SEND!';                      
  end;
run; 
&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 22:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/947974#M45420</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-17T22:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Write fields of a table to the body of an Email</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/948031#M45421</link>
      <description>&lt;P&gt;Thanks for the feedback Tom!&amp;nbsp; The first example is what I'm going for, with all results in a single email.&amp;nbsp; I'm trying your suggestion, but can't figure out how to write a line of text, then dump the table outputs.&amp;nbsp; It wants to write the line of text X number of times, to go with the table results.&amp;nbsp; thoughts?&amp;nbsp; Here's my code, and below it is the result (with "Here are your results" repeated).&amp;nbsp; Thanks again!!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro runemail;
	filename outmail email 
		to=&amp;amp;toEmail. 
		from=&amp;amp;fromEmail. ;

	data _null_;
	file outmail;
	put "Here are your results:";
	put;

     set want;
  	 put Member= Amount=;

	run;

%mend runemail;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Here are your results:

MEMBER=1234567891 AMOUNT=10
Here are your results:

MEMBER=1234567892 AMOUNT=6
Here are your results:

MEMBER=1234567893 AMOUNT=5
Here are your results:

MEMBER=1122334455 AMOUNT=4
Here are your results:&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Oct 2024 12:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/948031#M45421</guid>
      <dc:creator>Rebecca_K</dc:creator>
      <dc:date>2024-10-18T12:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Write fields of a table to the body of an Email</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/948033#M45422</link>
      <description>&lt;P&gt;Only write the static text the FIRST time the data step executes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if _n_=1 then put ....&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Oct 2024 12:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/948033#M45422</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-18T12:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Write fields of a table to the body of an Email</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/948034#M45423</link>
      <description>&lt;P&gt;Perfect!&amp;nbsp; Thanks for your help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 12:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-fields-of-a-table-to-the-body-of-an-Email/m-p/948034#M45423</guid>
      <dc:creator>Rebecca_K</dc:creator>
      <dc:date>2024-10-18T12:51:45Z</dc:date>
    </item>
  </channel>
</rss>

