<?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: Including macro variable in email in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Including-macro-variable-in-email/m-p/875692#M346009</link>
    <description>&lt;P&gt;You have already asked this question and received a number of valuable answers, including &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-include-macro-variable-in-an-email/m-p/875094#M345763" target="_self"&gt;one answer&lt;/A&gt; and a &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-include-macro-variable-in-an-email/m-p/875097#M345766" target="_self"&gt;second answer&lt;/A&gt; both of which I regard as correct.&lt;/P&gt;</description>
    <pubDate>Sun, 14 May 2023 18:48:01 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-05-14T18:48:01Z</dc:date>
    <item>
      <title>Including macro variable in email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-macro-variable-in-email/m-p/874999#M345728</link>
      <description>&lt;P&gt;I've created a macro to check the observation counts of tables and include the names of any empty tables inside a macro variable. Inside of the macro, I'm trying to email myself a message detailing which, if any, tables are empty. However, the value of my macro variable does not get included in my email. What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've included a reprex below:&lt;/P&gt;&lt;PRE&gt;/*list of table names*/
%let tables = a b c;

/*row counts corresponding to table names in &amp;amp;tables*/
%let table_row_counts = 0 100 500;

%let number_of_tables = %sysfunc(countw(&amp;amp;modules));

/*check to see if tables are empty, if any are, then include email with the names of the empty tables*/
%macro validate();
&lt;BR /&gt;        /*test macro variable. this macro var is properly included in email*/
	%let test = test message;

	%let empty_tables = ;

	%do i = 1 %to &amp;amp;number_of_tables;
		%if %scan(&amp;amp;table_row_counts,&amp;amp;i) = 0 %then %do;
			%let empty_tables = %scan(&amp;amp;tables,&amp;amp;i) &amp;amp;empty_tables;
		%end;
	%end; 

	%let total_empty_tables = %sysfunc(countw(&amp;amp;tables));
	%put &amp;amp;empty_tables; /*resolves to "a"*/

        /*email will display the value of &amp;amp;test, but not &amp;amp;empty_tables (value should be displayed as "a"*/
	%if &amp;amp;total_empty_tables &amp;gt; 0 %then %do;
		FILENAME Mailbox EMAIL ('youremail@email.com')
		Subject='Empty Table Alert';
		DATA _NULL_;
		FILE Mailbox;
		put "&amp;amp;test";
		PUT "The following tables are empty";
		put &amp;amp;empty_tables;
		RUN;
	%return;
	%end;
%mend;
%validate();&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 May 2023 15:30:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-macro-variable-in-email/m-p/874999#M345728</guid>
      <dc:creator>everyone</dc:creator>
      <dc:date>2023-05-10T15:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Including macro variable in email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-macro-variable-in-email/m-p/875691#M346008</link>
      <description>&lt;P&gt;Suggest running the macro with MPRINT on and checking the log. &amp;nbsp;Do you get any errors or bad notes? &amp;nbsp;I would think it would be throwing unititialized variable notes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I noticed:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let empty_tables = %scan(&amp;amp;tables,&amp;amp;i) &amp;amp;empty_tables;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your comment says:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;empty_tables; /*resolves to "a"*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But from the code you posted, I don't see anything that will add quotation marks. &amp;nbsp;Suggest trying:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let empty_tables = "%scan(&amp;amp;tables,&amp;amp;i)" &amp;amp;empty_tables;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 May 2023 17:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-macro-variable-in-email/m-p/875691#M346008</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-05-14T17:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Including macro variable in email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-macro-variable-in-email/m-p/875692#M346009</link>
      <description>&lt;P&gt;You have already asked this question and received a number of valuable answers, including &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-include-macro-variable-in-an-email/m-p/875094#M345763" target="_self"&gt;one answer&lt;/A&gt; and a &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-include-macro-variable-in-an-email/m-p/875097#M345766" target="_self"&gt;second answer&lt;/A&gt; both of which I regard as correct.&lt;/P&gt;</description>
      <pubDate>Sun, 14 May 2023 18:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-macro-variable-in-email/m-p/875692#M346009</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-14T18:48:01Z</dc:date>
    </item>
  </channel>
</rss>

