<?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 do a count for a date column on 3 tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-count-for-a-date-column-on-3-tables/m-p/823146#M325028</link>
    <description>&lt;P&gt;Suggest, if you are only interested in a few variables that you add a VAR statement to the Proc Compare code.&lt;/P&gt;
&lt;P&gt;The VAR statement will restrict the comparisons to only the variables on the statement. So supply the date variables of interest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With Proc Compare you also want to sort the data sets in some fashion that the order makes sense for comparing records. I am not sure that dates alone are appropriate if you want to see if the dates associated with some characteristic such as company, person, instrument or other grouping.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jul 2022 15:40:58 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-07-13T15:40:58Z</dc:date>
    <item>
      <title>How to do a count for a date column on 3 tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-count-for-a-date-column-on-3-tables/m-p/823054#M324996</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have three tables all named diffusion in three different directories. They have the same columns. I have to compare these three tables to know if I have the same values/rows in all 3 tables for the year '2021'. The tables contain values for 2021 and 2022.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really don't know where and how to start.&lt;/P&gt;&lt;P&gt;I want to do it using proc sql.&lt;/P&gt;&lt;P&gt;(I have erased some information in the picture due to confidentiality).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-07-13 101850.png"&gt;&lt;img src="https://communities.sas.com/skins/images/2FD96521DCF95C42FE57BF2A7CB72678/responsive_peak/images/image_not_found.png" alt="Screenshot 2022-07-13 101850.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 06:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-count-for-a-date-column-on-3-tables/m-p/823054#M324996</guid>
      <dc:creator>MILKYLOVE</dc:creator>
      <dc:date>2022-07-13T06:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a count for a date column on 3 tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-count-for-a-date-column-on-3-tables/m-p/823060#M324999</link>
      <description>&lt;P&gt;The SAS tool for comparing datasets is PROC COMPARE.&lt;/P&gt;
&lt;P&gt;Are there keys in your datasets which identify unique observations?&lt;/P&gt;
&lt;P&gt;Use a WHERE condition to select for the year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For in-depth help, supply usable examples for at least two datasets in data steps with datalines; pictures are not usable.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 07:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-count-for-a-date-column-on-3-tables/m-p/823060#M324999</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-13T07:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a count for a date column on 3 tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-count-for-a-date-column-on-3-tables/m-p/823063#M325001</link>
      <description>&lt;P&gt;So I have used the below code to compare for dates from 1Jan2021 to 1JAN2022&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I receive 120,000 observations and it's difficult for me to point out where the base and compare are not the same. How can I search for the anomalies in the end result please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data date;
     format date_debut date9.;
     format date_fin date9.;
     annee_2021 = year(date())-1;
     annee_2022 = year(date());
     date_debut = mdy(1,1, input(annee_2021, best.));
     date_fin = mdy(1,1, input(annee_2022, best.));
     call symput('date_debut', date_debut);
     call symput('date_fin', date_fin);
run;


proc sql;
create table t1 as 
select * from adobe.diffusion 
where ADB_DATE_MODIFICATION &amp;gt;= dhms(&amp;amp;date_debut,0,0,0)
and ADB_DATE_MODIFICATION &amp;lt;= dhms(&amp;amp;date_fin,0,0,0);
quit;


proc sql;
create table t2 as 
select * from prod.diffusion 
where ADB_DATE_MODIFICATION &amp;gt;= dhms(&amp;amp;date_debut,0,0,0)
and ADB_DATE_MODIFICATION &amp;lt;= dhms(&amp;amp;date_fin,0,0,0);
quit;

proc sort data = t1 out = diff1_bydate;
by ADB_DATE_MODIFICATION;
run;

proc sort data = t2 out = diff2_bydate;
by ADB_DATE_MODIFICATION;
run;

proc compare base = diff1_bydate compare = diff2_bydate
out = result outnoequal outbase outcomp outdif
noprint;
id ADB_DATE_MODIFICATION;
title 'Comparaison' ;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jul 2022 08:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-count-for-a-date-column-on-3-tables/m-p/823063#M325001</guid>
      <dc:creator>MILKYLOVE</dc:creator>
      <dc:date>2022-07-13T08:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a count for a date column on 3 tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-count-for-a-date-column-on-3-tables/m-p/823146#M325028</link>
      <description>&lt;P&gt;Suggest, if you are only interested in a few variables that you add a VAR statement to the Proc Compare code.&lt;/P&gt;
&lt;P&gt;The VAR statement will restrict the comparisons to only the variables on the statement. So supply the date variables of interest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With Proc Compare you also want to sort the data sets in some fashion that the order makes sense for comparing records. I am not sure that dates alone are appropriate if you want to see if the dates associated with some characteristic such as company, person, instrument or other grouping.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 15:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-count-for-a-date-column-on-3-tables/m-p/823146#M325028</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-13T15:40:58Z</dc:date>
    </item>
  </channel>
</rss>

