<?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: Building email address using %let statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299709#M312227</link>
    <description>&lt;P&gt;Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for responding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The system macro variable _clientuserid produces the userid enclosed in single quotes (e.g. 'tbarker'). To mimic this in your code, you would need to put single quotes around the word 'awesome'. Your second let statement would then produce "&lt;A href="mailto:'awesome'@smud.org" target="_blank"&gt;'awesome'@smud.org&lt;/A&gt;", retaining the single quotes around 'awesome'. That causes an error when used in the emailid option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I, too, thought it should be as easy as %let my_login = &lt;SPAN class="token string"&gt;"&amp;amp;_clientuserid.@smud.org"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;, but it's the embedded single quotes in the _clientuserid return value&amp;nbsp;that cause the problem, requiring the compress function to get rid of them. And when I try to enclose the my_login value (as I coded it) in double quotes using a variety of methods, SAS produces various errors. Thus the second let statement to enclose the value from the first let statement in double quotes.&lt;/P&gt;</description>
    <pubDate>Tue, 20 Sep 2016 23:16:35 GMT</pubDate>
    <dc:creator>TBarker</dc:creator>
    <dc:date>2016-09-20T23:16:35Z</dc:date>
    <item>
      <title>Building email address using %let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299650#M312225</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to build an email address macro variable for use with the 'emailid' system option for sending email from a SAS program, using the user's network ID (as returned by the automatic macro variable _clientuserid). The program in question may be run by various users and I don't want anyone to have to hard code their email address in the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've modified the macro variable code every way I can think of, but except for building it with two macro vars, I always end up with the variable&amp;nbsp;not resolving correctly in the options statement. Is it possible to do it in one %let statement? I feel there must be one simple thing I'm overlooking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my code that works&amp;nbsp;using two %let statements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let my_login = %sysfunc(compress(&amp;amp;_clientuserid.'@smud.org',"'"));
%let sender = "&amp;amp;my_login";

options emailsys=smtp emailhost=&amp;lt;oursystem&amp;gt; emailport = &amp;lt;ourport&amp;gt; emailed=&amp;amp;sender.;&lt;BR /&gt;&lt;BR /&gt;filename mymail email to=&amp;lt;recipients&amp;gt; subject="SAS test email";&lt;BR /&gt;data _null_;&lt;BR /&gt;	file mymail;&lt;BR /&gt;	put "This is a test";&lt;BR /&gt;run;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am running SAS EG 5.1, processing on a UNIX server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tamara&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 19:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299650#M312225</guid>
      <dc:creator>TBarker</dc:creator>
      <dc:date>2016-09-20T19:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Building email address using %let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299657#M312226</link>
      <description>&lt;P&gt;Unless I'm missing something, isn't it:&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;%let _clientuserid=awesome;
%let my_login = "&amp;amp;_clientuserid.@smud.org";
%put &amp;amp;my_login;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Sep 2016 19:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299657#M312226</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-20T19:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Building email address using %let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299709#M312227</link>
      <description>&lt;P&gt;Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for responding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The system macro variable _clientuserid produces the userid enclosed in single quotes (e.g. 'tbarker'). To mimic this in your code, you would need to put single quotes around the word 'awesome'. Your second let statement would then produce "&lt;A href="mailto:'awesome'@smud.org" target="_blank"&gt;'awesome'@smud.org&lt;/A&gt;", retaining the single quotes around 'awesome'. That causes an error when used in the emailid option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I, too, thought it should be as easy as %let my_login = &lt;SPAN class="token string"&gt;"&amp;amp;_clientuserid.@smud.org"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;, but it's the embedded single quotes in the _clientuserid return value&amp;nbsp;that cause the problem, requiring the compress function to get rid of them. And when I try to enclose the my_login value (as I coded it) in double quotes using a variety of methods, SAS produces various errors. Thus the second let statement to enclose the value from the first let statement in double quotes.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 23:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299709#M312227</guid>
      <dc:creator>TBarker</dc:creator>
      <dc:date>2016-09-20T23:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Building email address using %let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299713#M312228</link>
      <description>&lt;P&gt;Not sure this is better than your current solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would use dequote + quote functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could probably nest your functions as well, using another %sysfunc and the quote function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let _clientuserid='awesome';
%let my_login = %sysfunc(quote(%sysfunc(dequote(&amp;amp;_clientuserid))@smud.org));
%put &amp;amp;my_login;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Sep 2016 00:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299713#M312228</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-21T00:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Building email address using %let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299714#M312229</link>
      <description>&lt;P&gt;And another option, move the quotes to the options statement and have no quotes in your macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 00:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299714#M312229</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-21T00:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Building email address using %let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299924#M312230</link>
      <description>&lt;P&gt;Quote/Dequote worked! Now it's just one let statement instead of two. Not a critical requirement, but I like to have as efficient code as possible. I'm sure I had tried the dequote function before, but I was messing with the code so much that I never got it to work in whichever iteration I tried it. And I for some reason had not tried the quote function. Sometimes you just need someone else to come at your problem with a clearer mind. Thank you for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 18:00:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-email-address-using-let-statement/m-p/299924#M312230</guid>
      <dc:creator>TBarker</dc:creator>
      <dc:date>2016-09-21T18:00:07Z</dc:date>
    </item>
  </channel>
</rss>

