<?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: Send emails to different users from SAS with embedded table that has unique user data from datas in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Send-emails-to-different-users-from-SAS-with-embedded-table-that/m-p/631011#M23846</link>
    <description>&lt;P&gt;I was able to resolve this by modifying Part B utilizing the macro I created in Part A.&amp;nbsp; It now runs each part in parallel creating the desired individual emails!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Solution&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;PROC REPORT DATA= &amp;amp;&amp;amp;EMPID_N&amp;amp;i nowd HEADLINE HEADSKIP&lt;/P&gt;</description>
    <pubDate>Tue, 10 Mar 2020 16:47:38 GMT</pubDate>
    <dc:creator>Ryan_G</dc:creator>
    <dc:date>2020-03-10T16:47:38Z</dc:date>
    <item>
      <title>Send emails to different users from SAS with embedded table that has unique user data from dataset</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Send-emails-to-different-users-from-SAS-with-embedded-table-that/m-p/630780#M23836</link>
      <description>&lt;P&gt;Hello SAS Gurus!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see the attached excel file that has the mock data to use for this.&amp;nbsp;&amp;nbsp;I need to send individual&amp;nbsp;emails to different users based on their schedule selections.&amp;nbsp;&amp;nbsp;The attached file is the base table where all the data resides.&amp;nbsp; What I need to do is embed,&amp;nbsp; for each user, what their schedule selections were (could have varying ranges 1-&amp;nbsp;whatever)&amp;nbsp;into the email (preferably as a table).&amp;nbsp; So for example,&amp;nbsp;&amp;nbsp; EMPID&amp;nbsp;(unique identifier field)&amp;nbsp;"0001" has submit 2 &amp;nbsp; schedules,&amp;nbsp; I need to imbed both of those from this table,&amp;nbsp; whereas&amp;nbsp; EMPID "0006" has 6 different selections and I'd need to include each of those in their email.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part A:&amp;nbsp; I'm not sure if this is the right/most efficient way to achieve this (open to any better solutions),&amp;nbsp; but my thought process is to&amp;nbsp;create unique SAS datasets for each of these users (so EMPID "0001" has their own dataset with their 2 schedules, and so on).&amp;nbsp;&amp;nbsp; I've done this using the code in Part A below.&amp;nbsp; This is a loop and works to create a table for each distinct EMPID.&lt;/P&gt;&lt;P&gt;Part B:&amp;nbsp; My next thought is to now pair this with code I'd see in prior posts,&amp;nbsp; that allow you embed a table into an email.&amp;nbsp; I can get this to work by itself, but I somehow need to partner this up with the macro in Part A,&amp;nbsp; so that as it creates each unique table, it's putting that into the email and sending respectively to each individual with their appropriate data, looping&amp;nbsp;until all unique users have been sent their individual&amp;nbsp;email with their specific&amp;nbsp;schedule information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greatly appreciate any insight/wisdom in how to make this work or an alternative method that accomplishes the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/**** PART A ******/&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Import_Sched_mock2;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Import_Sched_mock;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;EMPID_N = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"A"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;||EMPID;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;IF&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; EMAIL_ADDR = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;""&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;THEN&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DELETE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;distinct&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; EMPID_N,count(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;distinct&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; EMPID_N) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; :EMPID_N1-,:c&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Import_Sched_mock2;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;&lt;I&gt;t&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i =&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;c;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create table &amp;amp;&amp;amp;EMPID_N&amp;amp;i as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from &lt;FONT face="Courier New" size="2"&gt;Import_Sched_mock2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;where EMPID_N=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;&amp;amp;EMPID_N&amp;amp;i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; t;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;t&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I&gt;/**** PART&amp;nbsp;B ******/&amp;nbsp; &lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;%macro&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; send_report_emails();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;EMPID_N;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename mymail email&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;type=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'TEXT/HTML'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;subject=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"TEST EMAILS-RG"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to=&amp;amp;EmailTo&lt;/P&gt;&lt;P&gt;cc=&amp;amp;EmailTo&lt;/P&gt;&lt;P&gt;from=&amp;amp;EmailFrom&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;importance=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"HIGH"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;file mymail;&lt;/P&gt;&lt;P&gt;/*ODS html body=temp style = noline; */&lt;/P&gt;&lt;P&gt;ODS html body=MYMAIL style = noline;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;ods html text = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Good Morning,"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;ods html text = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;""&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/***** need to figure out this part of the code to have it read the variable table names *******/&lt;/P&gt;&lt;P&gt;PROC REPORT DATA= &lt;FONT face="Courier New" size="2"&gt;Import_Sched_mock2&lt;/FONT&gt; nowd HEADLINE HEADSKIP&lt;/P&gt;&lt;P&gt;style (report) = {background = white&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;font_face = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Verdana"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; font_size = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;7&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;pt just=left }&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;style (column) = {background = white CELLHEIGHT = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2.5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;font_face = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Verdana"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; font_size = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;7&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;pt just=left}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;style (header) = {foreground = cx5e2750 font_face=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Verdana"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;font_size = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;pt just=left&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;background = white} ;&lt;/P&gt;&lt;P&gt;columns&lt;/P&gt;&lt;P&gt;Schedule_Name&lt;/P&gt;&lt;P&gt;Type&lt;/P&gt;&lt;P&gt;Start_Time&lt;/P&gt;&lt;P&gt;End_Time;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;DEFINE Schedule_Name / &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'Schedule Name'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;define Type / &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'Type'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;define Start_Time / &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Start Time"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;define End_Time / &lt;FONT color="#800080" face="Courier New" size="2"&gt;"End Time"&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;ods html text = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Have a Great Day."&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods _all_ close;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; send_report_emails;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;send_report_emails&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 11:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Send-emails-to-different-users-from-SAS-with-embedded-table-that/m-p/630780#M23836</guid>
      <dc:creator>Ryan_G</dc:creator>
      <dc:date>2020-03-10T11:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Send emails to different users from SAS with embedded table that has unique user data from datas</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Send-emails-to-different-users-from-SAS-with-embedded-table-that/m-p/631011#M23846</link>
      <description>&lt;P&gt;I was able to resolve this by modifying Part B utilizing the macro I created in Part A.&amp;nbsp; It now runs each part in parallel creating the desired individual emails!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Solution&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;PROC REPORT DATA= &amp;amp;&amp;amp;EMPID_N&amp;amp;i nowd HEADLINE HEADSKIP&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 16:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Send-emails-to-different-users-from-SAS-with-embedded-table-that/m-p/631011#M23846</guid>
      <dc:creator>Ryan_G</dc:creator>
      <dc:date>2020-03-10T16:47:38Z</dc:date>
    </item>
  </channel>
</rss>

