<?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: For each loop on each returned observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/For-each-loop-on-each-returned-observation/m-p/233902#M42730</link>
    <description>&lt;P&gt;Depending on your environment/network, yes, this is possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can check out some references to system options&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001472105.htm" target="_blank"&gt;here&lt;/A&gt;, as well as the links at the bottom of that page to the other system e-mail options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my experience, I've only had to specify EMAILSYS , EMAILHOST, and &amp;nbsp;EMAILPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I only have the ability to use SMTP on my environment so I can't speak to other protocalls but if I wanted to do this it would look similar to this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data dummy;
  infile datalines dlm="#";
	input location &amp;amp; $16. count 10.;
	datalines;
ABC# 5
DEF# 6
GHI# 8
JKL# 14
;

options emailsys = SMTP emailhost = smtp.domain.com emailport=25 nonotes nosource;


FILENAME outbox EMAIL;
DATA _NULL_;
FILE outbox
TO=("sender@domain.com")
FROM=("recipient@domain.com")
SUBJECT=("Subject" );
set dummy(where=(count &amp;gt;7));

PUT " ";
PUT location count;
PUT "Any other body you would want to say in the e-mail";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That would be the most basic listing type output in the body of the e-mail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, you could create a pdf, rtf, html, etc. document, and attach that to the e-mail instead of printing the data output to the body of the e-mail. You would add a path to the file you just created on the FILE statment, e.g.,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods pdf "path-to-file.ext";

proc print data=dummy;
where count &amp;gt; 7;
run;

ods pdf close;

FILENAME outbox EMAIL;

DATA _NULL_;
FILE outbox
TO=("sender@domain.com")
FROM=("recipient@domain.com")
SUBJECT=("Subject" )
ATTACH=("path-to-file.ext");

PUT "Hello.";
PUT " ";
PUT "Please see the attachment for dummy counts greater than 7.";
PUT " ";

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These are canned examples that I've used in my environment so YMMV, but they've worked for me.&lt;/P&gt;</description>
    <pubDate>Mon, 09 Nov 2015 20:47:36 GMT</pubDate>
    <dc:creator>JoshB</dc:creator>
    <dc:date>2015-11-09T20:47:36Z</dc:date>
    <item>
      <title>For each loop on each returned observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-each-loop-on-each-returned-observation/m-p/233900#M42729</link>
      <description>&lt;P&gt;So I have a dataset that is similar to the one below but with a few more columns. What I would like to know is if it is possible to do something similar to a foreach loop on each observation and use the observation variables to send an email. For example, if I wanted to pull from the below dataset everything over 7 and then email XXX@blah.com a message is that possible? I appreciate any assistance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data dummy;
infile datalines dlm='#';
input location &amp;amp; $16. count 10.;
datalines;
ABC# 5
DEF# 6
GHI# 8
JKL# 14
;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Nov 2015 20:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-each-loop-on-each-returned-observation/m-p/233900#M42729</guid>
      <dc:creator>AndyJ_</dc:creator>
      <dc:date>2015-11-09T20:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: For each loop on each returned observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-each-loop-on-each-returned-observation/m-p/233902#M42730</link>
      <description>&lt;P&gt;Depending on your environment/network, yes, this is possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can check out some references to system options&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001472105.htm" target="_blank"&gt;here&lt;/A&gt;, as well as the links at the bottom of that page to the other system e-mail options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my experience, I've only had to specify EMAILSYS , EMAILHOST, and &amp;nbsp;EMAILPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I only have the ability to use SMTP on my environment so I can't speak to other protocalls but if I wanted to do this it would look similar to this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data dummy;
  infile datalines dlm="#";
	input location &amp;amp; $16. count 10.;
	datalines;
ABC# 5
DEF# 6
GHI# 8
JKL# 14
;

options emailsys = SMTP emailhost = smtp.domain.com emailport=25 nonotes nosource;


FILENAME outbox EMAIL;
DATA _NULL_;
FILE outbox
TO=("sender@domain.com")
FROM=("recipient@domain.com")
SUBJECT=("Subject" );
set dummy(where=(count &amp;gt;7));

PUT " ";
PUT location count;
PUT "Any other body you would want to say in the e-mail";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That would be the most basic listing type output in the body of the e-mail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, you could create a pdf, rtf, html, etc. document, and attach that to the e-mail instead of printing the data output to the body of the e-mail. You would add a path to the file you just created on the FILE statment, e.g.,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods pdf "path-to-file.ext";

proc print data=dummy;
where count &amp;gt; 7;
run;

ods pdf close;

FILENAME outbox EMAIL;

DATA _NULL_;
FILE outbox
TO=("sender@domain.com")
FROM=("recipient@domain.com")
SUBJECT=("Subject" )
ATTACH=("path-to-file.ext");

PUT "Hello.";
PUT " ";
PUT "Please see the attachment for dummy counts greater than 7.";
PUT " ";

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These are canned examples that I've used in my environment so YMMV, but they've worked for me.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2015 20:47:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-each-loop-on-each-returned-observation/m-p/233902#M42730</guid>
      <dc:creator>JoshB</dc:creator>
      <dc:date>2015-11-09T20:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: For each loop on each returned observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-each-loop-on-each-returned-observation/m-p/233995#M42761</link>
      <description>&lt;P&gt;filename MyMail Email&lt;BR /&gt;from = "yyy.blah.com"&lt;BR /&gt;to = "xxx.blah.com"&lt;BR /&gt;subject = "Locations whose count is &amp;gt;7 "&lt;BR /&gt;type = "text/html";&lt;/P&gt;
&lt;P&gt;ods html body = MyMail style=journal;&lt;BR /&gt;title1 "Hi All,";&lt;BR /&gt;title2 "Please find below Locations whose count is greate than 7";&lt;BR /&gt;proc report data = Dummy;&lt;BR /&gt;where count &amp;gt; 7;&lt;BR /&gt;footnote1 "Thanks and Regards,";&lt;BR /&gt;footnote2 "YYY";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;ods _all_ close;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 12:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-each-loop-on-each-returned-observation/m-p/233995#M42761</guid>
      <dc:creator>MadhuKorni</dc:creator>
      <dc:date>2015-11-10T12:31:03Z</dc:date>
    </item>
  </channel>
</rss>

