<?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 Checking the contents of a Table in SAS everyday in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Checking-the-contents-of-a-Table-in-SAS-everyday/m-p/888453#M351014</link>
    <description>&lt;P&gt;I want to design a query which can check the contents of a Table every day in a SAS system.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query should be able to :&lt;/P&gt;&lt;P&gt;- count the total no of records in the table everyday&lt;/P&gt;&lt;P&gt;-&amp;nbsp; find the difference of records between yesterday and today.&lt;/P&gt;&lt;P&gt;-&amp;nbsp;Check for valid values in a column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Aug 2023 18:38:02 GMT</pubDate>
    <dc:creator>Rhino84</dc:creator>
    <dc:date>2023-08-08T18:38:02Z</dc:date>
    <item>
      <title>Checking the contents of a Table in SAS everyday</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Checking-the-contents-of-a-Table-in-SAS-everyday/m-p/888453#M351014</link>
      <description>&lt;P&gt;I want to design a query which can check the contents of a Table every day in a SAS system.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query should be able to :&lt;/P&gt;&lt;P&gt;- count the total no of records in the table everyday&lt;/P&gt;&lt;P&gt;-&amp;nbsp; find the difference of records between yesterday and today.&lt;/P&gt;&lt;P&gt;-&amp;nbsp;Check for valid values in a column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 18:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Checking-the-contents-of-a-Table-in-SAS-everyday/m-p/888453#M351014</guid>
      <dc:creator>Rhino84</dc:creator>
      <dc:date>2023-08-08T18:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Checking the contents of a Table in SAS everyday</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Checking-the-contents-of-a-Table-in-SAS-everyday/m-p/888477#M351023</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's better to always mention the SAS version you are using.&lt;/P&gt;
&lt;P&gt;(If you are using in-memory CAS tables in SAS Viya, the responses might be a bit different &lt;BR /&gt;... compared to V9 *.sas7bdat on-disk tables).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To know about your SAS version, submit:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%PUT &amp;amp;=sysvlong4;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. To&amp;nbsp;&lt;SPAN&gt;count the total no of records in the table everyday&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Use this piece of code :&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET Table2LevelName=SASHELP.DMINE;

data _NULL_;
 if 0 then set &amp;amp;Table2LevelName. nobs=count;
 call symput('NumberOfRows',trim(left(put(count,12.))));
 STOP;
run;

%PUT &amp;amp;=NumberOfRows;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2.&amp;nbsp;&lt;/SPAN&gt;find the difference of records between yesterday and today.&lt;BR /&gt;Use PROC COMPARE&lt;BR /&gt;SAS® 9.4 and SAS® Viya® 3.5 Programming Documentation&lt;BR /&gt;Base SAS Procedures Guide&lt;BR /&gt;COMPARE Procedure&lt;BR /&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0c1y14wyd3u7yn1dmfcpaejllsn.htm" target="_blank" rel="noopener"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0c1y14wyd3u7yn1dmfcpaejllsn.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Check for valid values in a column.&lt;/P&gt;
&lt;P&gt;Please give more info. I can think of 1000 ways to do this depending on what exactly is required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR, Koen&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 21:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Checking-the-contents-of-a-Table-in-SAS-everyday/m-p/888477#M351023</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-08-08T21:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Checking the contents of a Table in SAS everyday</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Checking-the-contents-of-a-Table-in-SAS-everyday/m-p/888483#M351027</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391324"&gt;@Rhino84&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;-&amp;nbsp; find the difference of records between yesterday and today.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Will you have yesterday's data set? If not you you will need to save the count from the previous day&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;-&amp;nbsp;Check for valid values in a column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Valid values? depends on your definition. If you have specific rules share them.&lt;/P&gt;
&lt;P&gt;Generally I enforce this with proper informats when reading values into SAS so that unacceptable values are treated as "invalid data" for specific values or report on ranges after reading. Depends on what you expect/mean by "check for valid" and what to do when encountering not valid values.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 22:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Checking-the-contents-of-a-Table-in-SAS-everyday/m-p/888483#M351027</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-08T22:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Checking the contents of a Table in SAS everyday</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Checking-the-contents-of-a-Table-in-SAS-everyday/m-p/888540#M351046</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/*Here is an example you can start with*/

%let before= D:\XiaKeShan\sas_file_WM- ETcath200_Datasets_2023_05_15 09_05_50  ;  *the path for yesterday dataset;
%let after=  D:\XiaKeShan\sas_file_WM- ETbox200_Datasets_2023_05_15 09_05_17   ;  *the path for today dataset;

libname before v9 "&amp;amp;before.";
libname after v9 "&amp;amp;after.";

%macro compare_dsn(first=,second= , output=);
proc sql;
create table &amp;amp;output. as
select * from  &amp;amp;second.
except
select * from  &amp;amp;first.
;
quit;
%mend;
proc datasets library=work kill memtype=data nolist nodetails;
quit;
data _null_;
 set sashelp.vtable(keep=memname libname where=(libname='AFTER'));
 call execute(catt('%compare_dsn(first=before.',memname,',second=after.',memname,', output=',memname,')'));
run;
proc sql; 
select memname label='Table Name',ifc(nlobs=0,'equal      ','not equal') as equal label='isEqual'
 from dictionary.tables 
  where libname='WORK' ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Aug 2023 11:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Checking-the-contents-of-a-Table-in-SAS-everyday/m-p/888540#M351046</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-08-09T11:27:31Z</dc:date>
    </item>
  </channel>
</rss>

