<?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 Macro to count records in multiple datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-count-records-in-multiple-datasets/m-p/550649#M152906</link>
    <description>&lt;P&gt;Hello, I am having an issue with something in SAS (version&amp;nbsp;9.4)&amp;nbsp;and could use some expertise! Basically my macro currently looks like this:&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 face="Courier New" size="2"&gt; count(*) &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;: thirtyfive_counts &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; history_upi, dummy_upi_clean, dummy_upi_76, history_upi_76;&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; yyy(when);&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; &amp;amp;when ne &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&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;%do&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;%include&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'G:\Groups\HHR\new 35 file.sas'&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;&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;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;yyy&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;thirtyfive_counts);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimately, I want this program(in the include statement)&amp;nbsp;to be run if there are any records in any of those 4 datasets (listed in the from statement). The issue I am having is if one of those datasets is empty (which will sometimes be the case) it is giving me an error and not running the program. However, if&amp;nbsp;I only list the datasets where this&amp;nbsp;is a record, it will work fine.&amp;nbsp;I would like it to run if there is an observation in any of the four datasets. Is this possible?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Apr 2019 14:21:47 GMT</pubDate>
    <dc:creator>sashelp123</dc:creator>
    <dc:date>2019-04-12T14:21:47Z</dc:date>
    <item>
      <title>Macro to count records in multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-count-records-in-multiple-datasets/m-p/550649#M152906</link>
      <description>&lt;P&gt;Hello, I am having an issue with something in SAS (version&amp;nbsp;9.4)&amp;nbsp;and could use some expertise! Basically my macro currently looks like this:&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 face="Courier New" size="2"&gt; count(*) &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;: thirtyfive_counts &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; history_upi, dummy_upi_clean, dummy_upi_76, history_upi_76;&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; yyy(when);&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; &amp;amp;when ne &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&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;%do&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;%include&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'G:\Groups\HHR\new 35 file.sas'&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;&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;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;yyy&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;thirtyfive_counts);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimately, I want this program(in the include statement)&amp;nbsp;to be run if there are any records in any of those 4 datasets (listed in the from statement). The issue I am having is if one of those datasets is empty (which will sometimes be the case) it is giving me an error and not running the program. However, if&amp;nbsp;I only list the datasets where this&amp;nbsp;is a record, it will work fine.&amp;nbsp;I would like it to run if there is an observation in any of the four datasets. Is this possible?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 14:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-count-records-in-multiple-datasets/m-p/550649#M152906</guid>
      <dc:creator>sashelp123</dc:creator>
      <dc:date>2019-04-12T14:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to count records in multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-count-records-in-multiple-datasets/m-p/550655#M152908</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let thirtyfive_counts=0;
proc sql no print;
select sum(nobs) into: thirtyfive_counts
from dictionary.tables
where libname = 'WORK' and lowercase(memname) in
("history_upi","dummy_upi_clean","dummy_upi_76","history_upi_76");
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is the correct way to determine this. If none of these datasets exists, you still get a zero.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 14:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-count-records-in-multiple-datasets/m-p/550655#M152908</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-12T14:29:56Z</dc:date>
    </item>
  </channel>
</rss>

