<?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: proc freq with empty dataset ?? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-freq-with-empty-dataset/m-p/837034#M41519</link>
    <description>Not really easily. Instead, it's better to set up your process to handle this weekend/holidays separately since it's likely looping somewhere anyways. &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 05 Oct 2022 19:38:19 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-10-05T19:38:19Z</dc:date>
    <item>
      <title>proc freq with empty dataset ??</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-freq-with-empty-dataset/m-p/836984#M41516</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to see the frequency of the Transaction_date in each dataset during one month.&amp;nbsp; Please note,&lt;/P&gt;
&lt;P&gt;that during the weekend, the dataset exists but there is no data in it, just the header (field name).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using a proc freq to get the frequency of the transactions_date per day, i.e. in each daily dataset but when the dataset is empty, proc freq is ignoring this dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wish to use proc freq to be able to check all the datasets (max 31 datasets) in one shot just to check the transaction repartition in term of transaction date per dataset for data quality purpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to get something even if the dataset is empty, like dataset x, transaction_date freq = 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a sample script.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
set sashelp.class;
stop;
run;

proc freq data=work.class;
weight Name / zeros;
table Name;
Title 'Name Frequency in dataset class';
run;

data class1;
set sashelp.class;
if _n_ eq 1 then output;
run;

proc freq data=work.class1;
table Name;
Title 'Name Frequency in dataset class1';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Oct 2022 15:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-freq-with-empty-dataset/m-p/836984#M41516</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2022-10-05T15:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq with empty dataset ??</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-freq-with-empty-dataset/m-p/837034#M41519</link>
      <description>Not really easily. Instead, it's better to set up your process to handle this weekend/holidays separately since it's likely looping somewhere anyways. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Oct 2022 19:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-freq-with-empty-dataset/m-p/837034#M41519</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-05T19:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq with empty dataset ??</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-freq-with-empty-dataset/m-p/837039#M41520</link>
      <description>&lt;P&gt;You could count some other way. Such as with PROC SQL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table counts as 
 select 'sashelp.class' as dsname length=41
      , count(*) as nobs
 from sashelp.class(obs=0)
;
quit;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could build a list of all of the possible dataset with the count defaulted to zero and then update it with the actual counts.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 20:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-freq-with-empty-dataset/m-p/837039#M41520</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-05T20:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq with empty dataset ??</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-freq-with-empty-dataset/m-p/837097#M41521</link>
      <description>&lt;P&gt;If you just need to know the number of rows per daily SAS table then something like below could work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.trans_20221001 work.trans_20221002 work.trans_20221003;
  set sashelp.class;
  output trans_20221001 trans_20221003;
run;

proc sql;
  select 
    input(scan(memname,-1,'_'),yymmdd8.) as transaction_dt format=date9.,
    nlobs as n_rows label='N Rows'
  from dictionary.tables
  where
    libname='WORK'
    and memname like 'TRANS_%'
    and 
      intnx('month',today(),-1,'s') &amp;lt;=
        input(scan(memname,-1,'_'),yymmdd8.)
          &amp;lt; today()
    ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Oct 2022 02:29:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-freq-with-empty-dataset/m-p/837097#M41521</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-10-06T02:29:06Z</dc:date>
    </item>
  </channel>
</rss>

