<?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: How to display dataset record in email template in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386093#M92439</link>
    <description>&lt;P&gt;So you have the emailing part working like you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, then I would probably use a function-style macro that returns a&amp;nbsp;count of the number of records in a dataset, see e.g. &lt;A href="http://www2.sas.com/proceedings/sugi26/p095-26.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi26/p095-26.pdf&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With that, you should be able to get what you want with something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_ ;
  file myemail2 ;
  put "Total number of records in dataset class= %countobs(class)" ;
  put "Total number of records in dataset school=%countobs(school)" ;
run ;&lt;/PRE&gt;</description>
    <pubDate>Mon, 07 Aug 2017 17:42:57 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2017-08-07T17:42:57Z</dc:date>
    <item>
      <title>How to display dataset record in email template</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386063#M92433</link>
      <description>&lt;P&gt;Hi Expert,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to display total records available for particular dataset in the email template. If not available, it should display zero. Can you please help me. I tried with macro but it is not displaying.&lt;/P&gt;
&lt;PRE&gt;data class;
set sashelp.class;
run;

data school;
input stud_id;
cards;
;
run;

FILENAME myemail2 EMAIL  to=("abc@yahoo.com" )
 Subject = "count check";

data _null_;
file myemail2;
Put "Total number of records in dataset class=" &amp;amp; 19;
Put "Total number of records in dataset school=" &amp;amp; 0;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Aug 2017 15:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386063#M92433</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2017-08-07T15:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to display dataset record in email template</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386073#M92434</link>
      <description>&lt;P&gt;Can you show how yout tried, with macros?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would expect the sample code you posted to throw an error, caused by the &amp;amp; outside of the quoted text.&amp;nbsp; But if you put the counts inside the quotes it should work fine, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;9    data _null_;
10   Put "Total number of records in dataset class=19";
11   Put "Total number of records in dataset school=0";
12   run;

Total number of records in dataset class=19
Total number of records in dataset school=0
&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Aug 2017 16:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386073#M92434</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-08-07T16:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to display dataset record in email template</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386082#M92436</link>
      <description>This is just an example I have given. I don't want to write manually. How to write the code such that it will display the exact line in email template.</description>
      <pubDate>Mon, 07 Aug 2017 17:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386082#M92436</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2017-08-07T17:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to display dataset record in email template</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386093#M92439</link>
      <description>&lt;P&gt;So you have the emailing part working like you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, then I would probably use a function-style macro that returns a&amp;nbsp;count of the number of records in a dataset, see e.g. &lt;A href="http://www2.sas.com/proceedings/sugi26/p095-26.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi26/p095-26.pdf&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With that, you should be able to get what you want with something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_ ;
  file myemail2 ;
  put "Total number of records in dataset class= %countobs(class)" ;
  put "Total number of records in dataset school=%countobs(school)" ;
run ;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Aug 2017 17:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386093#M92439</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-08-07T17:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to display dataset record in email template</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386473#M92565</link>
      <description>&lt;P&gt;Thanks for the information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use the suggested code but the email body do not resolve the code. It displays like below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Total number of records in dataset class= %countobs(class) Total number of records in dataset school=%countobs(school)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 04:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386473#M92565</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2017-08-09T04:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to display dataset record in email template</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386542#M92594</link>
      <description>&lt;P&gt;Did you define&amp;nbsp;a macro named %countobs() before you ran that code?&amp;nbsp; That is the first step.&amp;nbsp; The paper I linked to has an example.&amp;nbsp; You need to compile the macro first.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 10:27:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386542#M92594</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-08-09T10:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to display dataset record in email template</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386763#M92676</link>
      <description>&lt;P&gt;Using the original code, add a check for the automatic variable &amp;amp;sysnobs (which captures the number of obs processed in that data step). &amp;nbsp;I tweaked the subject so you can also see the counts in the subject without opening the message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;                                                                                                                             
set sashelp.class;                                                                                                                      
run;                                                                                                                                    
%let obs_class=&amp;amp;sysnobs;                                                                                                                
                                                                                                                                        
data school;                                                                                                                            
input stud_id;                                                                                                                          
cards;                                                                                                                                  
;                                                                                                                                       
run;                                                                                                                                    
%let obs_school=&amp;amp;sysnobs;                                                                                                               
                                                                                                                                        
FILENAME myemail2 EMAIL  to=("abc@yahoo.com" )                                                                                          
 Subject = "count check: class=&amp;amp;obs_class school=&amp;amp;obs_school";                                                                          
                                                                                                                                        
data _null_;                                                                                                                            
file myemail2;                                                                                                                          
Put "Total number of records in dataset class=&amp;amp;obs_class";                                                                              
Put "Total number of records in dataset school=&amp;amp;obs_school";                                                                            
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Aug 2017 18:45:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/386763#M92676</guid>
      <dc:creator>DaveHorne</dc:creator>
      <dc:date>2017-08-09T18:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to display dataset record in email template</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/387239#M92824</link>
      <description>Thanks for the solution</description>
      <pubDate>Fri, 11 Aug 2017 07:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-dataset-record-in-email-template/m-p/387239#M92824</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2017-08-11T07:00:22Z</dc:date>
    </item>
  </channel>
</rss>

