<?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: Summary report of duplicate values from multiple tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600368#M173522</link>
    <description>&lt;P&gt;EDITED.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data T1 T2 T3 T4 T5;
  do I=1 to 1000;
    if ranuni(0)&amp;gt;.6 then output T1;   
    if ranuni(0)&amp;gt;.6 then output T2;   
    if ranuni(0)&amp;gt;.6 then output T3;   
    if ranuni(0)&amp;gt;.6 then output T4;   
    if ranuni(0)&amp;gt;.6 then output T5;
  end;
run;

%macro intersect(list= T1 T2 T3 T4 T5  );
%let n=%sysfunc(countw(&amp;amp;list , %str( ) ));

proc sql;
create table temp as

%do i=1 %to &amp;amp;n ;
%let a=%scan(&amp;amp;list,&amp;amp;i,%str( ));
%do j=1 %to &amp;amp;n ;
%let b=%scan(&amp;amp;list,&amp;amp;j,%str( ));

select "&amp;amp;a" as dsn1 length=40,"&amp;amp;b" as dsn2 length=40,count(*) as n from(
select * from &amp;amp;a 
intersect
select * from &amp;amp;b 
)

%if &amp;amp;i ne &amp;amp;n or &amp;amp;j ne &amp;amp;n %then %do; union %end;

%end;
%end;

;quit;

%mend;

options mprint mlogic symbolgen;
%intersect()

proc transpose data=temp out=want(drop=_:);
by dsn1;
id dsn2;
var n;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 30 Oct 2019 13:31:35 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2019-10-30T13:31:35Z</dc:date>
    <item>
      <title>Summary report of duplicate values from multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600126#M173387</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 5 datasets (set1 to set5) containing the same variable (eg : var1). Those 5 datasets are 5 different sources.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By example,&lt;/P&gt;
&lt;P&gt;set1 contains 5506 var1&lt;/P&gt;
&lt;P&gt;set2 contains 6371 var1&lt;/P&gt;
&lt;P&gt;set3 contains 56 var1&lt;/P&gt;
&lt;P&gt;set4 contains 1237 var1&lt;/P&gt;
&lt;P&gt;set5 contains 6371 var1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, there's a lot of duplicates of var1 between those datasets.&lt;/P&gt;
&lt;P&gt;(By the way, those totals were made with a PROC SQL and select distinct, so in each set there's no duplicate value.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to produce a summary report that could ventilate those duplicates between the 5 datasets?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say, for example, that in set1 there's 2333 var1 which are also in set2.&lt;/P&gt;
&lt;P&gt;I would like to have a table (dataset) like a report which will display as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set1&amp;nbsp; &amp;nbsp; set2&amp;nbsp; &amp;nbsp;set3&amp;nbsp; &amp;nbsp;set4&amp;nbsp; &amp;nbsp;set5&lt;/P&gt;
&lt;P&gt;set1&amp;nbsp; &amp;nbsp;5506&amp;nbsp; &amp;nbsp;2333 ...........................&lt;/P&gt;
&lt;P&gt;set2&amp;nbsp; &amp;nbsp;2333&amp;nbsp; &amp;nbsp;6371 ............................&lt;/P&gt;
&lt;P&gt;set3&amp;nbsp; &amp;nbsp; .............................................&lt;/P&gt;
&lt;P&gt;set4&amp;nbsp; &amp;nbsp;...............................................&lt;/P&gt;
&lt;P&gt;set5 ...................................................&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this something possible?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 17:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600126#M173387</guid>
      <dc:creator>jpprovost</dc:creator>
      <dc:date>2019-10-29T17:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Summary report of duplicate values from multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600176#M173408</link>
      <description>&lt;P&gt;How do you show values that are present in 3 tables?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 20:56:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600176#M173408</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-10-29T20:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Summary report of duplicate values from multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600180#M173410</link>
      <description>&lt;P&gt;If you were to first merge the 5 datasets, by VAR1, then for each VAR1 value you could write out observations with a collection of ROW and COL values.&amp;nbsp; Let's say that for VAR1=88,&amp;nbsp; it is present in datasets DS1, DS3, and DS5.&amp;nbsp; The you could write out these observations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ROW    COL
SET1   SET1
SET3   SET1
SET5   SET1&lt;BR /&gt;SET3   SET3&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; &amp;nbsp;&amp;nbsp; /*Editted addition */&lt;/SPAN&gt;&lt;BR /&gt;SET5   SET3&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; &amp;nbsp;&amp;nbsp; /*Editted addition */&lt;/SPAN&gt;&lt;BR /&gt;SET5   SET5&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; &amp;nbsp;&amp;nbsp; /*Editted addition */&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;The you could just do a crosstabulation of ROW * COL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sort data=ds1; by var1; run;
proc sort data=ds2; by var1; run;
proc sort data=ds3; by var1; run;
proc sort data=ds4; by var1; run;
proc sort data=ds5; by var1; run;

data want (keep=row col var1 pattern);
  length row col $4;
  merge ds1 (in=in1) ds2 (in=in2) ds3 (in=in3) ds4 (in=in4) ds5 (in=in5);
  by var1;

  array _in {5} in1-in5;
  do c=1 to 5;
    col=cats('SET',c);
    if _in{c}=1 then do r=c to 5;
      row=cats('SET',r);
      if _in{r}=1 then output;
    end;
  end;
run;

proc tabulate data=want  noseps;
  class row  col;
  table row=' ' , col=' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 21:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600180#M173410</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-29T21:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Summary report of duplicate values from multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600182#M173411</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;How do you show values that are present in 3 tables?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I was thinking of something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test ABC;
set set1 (IN=A)
set2 (IN=B)
set3 (IN=C);
IF A AND B AND C THEN OUTPUT ABC;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I am not sure...&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 21:19:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600182#M173411</guid>
      <dc:creator>jpprovost</dc:creator>
      <dc:date>2019-10-29T21:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Summary report of duplicate values from multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600199#M173419</link>
      <description>&lt;P&gt;I would try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set set1 set2 set3 set4 set5 indsname=dsn;
fromDS = scan(dsn, 2);
run;

proc sort data=test; by var1 fromDS; run;

data temp;
length DS $100;
do until(last.var1);
	set test; by var1;
	ds = catx("-", ds, fromDS); 
	end;
keep var1 DS;
run;

proc sql;
create table want as
select DS, count(*) as n
from temp
group by DS;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 22:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600199#M173419</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-10-29T22:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Summary report of duplicate values from multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600219#M173430</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; I was thinking of something like this:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This does not answer the question.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You have a multidimensional&amp;nbsp;crossing. How do you want to show it?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;'s solution give you a summarised overview (WANT2 below).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You could&amp;nbsp;also want a detailed&amp;nbsp;&lt;/SPAN&gt;overview (WANT1 below).&lt;/P&gt;
&lt;P&gt;Or anything in between.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data T1 T2 T3 T4 T5;
  do I=1 to 1000;
    if ranuni(0)&amp;gt;.6 then output T1;   
    if ranuni(0)&amp;gt;.6 then output T2;   
    if ranuni(0)&amp;gt;.6 then output T3;   
    if ranuni(0)&amp;gt;.6 then output T4;   
    if ranuni(0)&amp;gt;.6 then output T5;
  end;
run;

data WANT1;
  merge T1(in=A) T2(in=B) T3(in=C) T4(in=D) T5(in=E);
  by I;
  src=catx('-',ifc(A,'T1',''),ifc(B,'T2',''),ifc(C,'T3',''),ifc(D,'T4',''),ifc(E,'T5',''));
run;

proc tabulate data=WANT1;
  class SRC;
  table src=' '*n=' '; 
run;

data WANT2 (keep=ROW COL );
  length ROW COL $4;
  merge T1(in=A) T2(in=B) T3(in=C) T4(in=D) T5(in=E);
  by I;
  array _in {5} in1-in5;
  do C=1 to 5;
    COL=cats('SET',C);
    if _in{C}=1 then do R=C to 5;
      ROW=cats('SET',R);
      if _in{r}=1 then output;
    end;
  end;
run;

proc tabulate data=WANT2  noseps;
  class ROW  COL;
  table ROW=' ' , COL=' '*n=' ';
run;&lt;/CODE&gt;&lt;A name="IDX" target="_blank"&gt;&lt;/A&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Tabulate: Table 1" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;SET1&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;SET2&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;SET3&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;SET4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;SET5&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;SET1&lt;/TH&gt;
&lt;TD class="r b data"&gt;405&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;SET2&lt;/TH&gt;
&lt;TD class="r b data"&gt;163&lt;/TD&gt;
&lt;TD class="r b data"&gt;389&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;SET3&lt;/TH&gt;
&lt;TD class="r b data"&gt;162&lt;/TD&gt;
&lt;TD class="r b data"&gt;151&lt;/TD&gt;
&lt;TD class="r b data"&gt;397&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;SET4&lt;/TH&gt;
&lt;TD class="r b data"&gt;151&lt;/TD&gt;
&lt;TD class="r b data"&gt;156&lt;/TD&gt;
&lt;TD class="r b data"&gt;161&lt;/TD&gt;
&lt;TD class="r b data"&gt;396&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;SET5&lt;/TH&gt;
&lt;TD class="r b data"&gt;158&lt;/TD&gt;
&lt;TD class="r b data"&gt;160&lt;/TD&gt;
&lt;TD class="r b data"&gt;167&lt;/TD&gt;
&lt;TD class="r b data"&gt;178&lt;/TD&gt;
&lt;TD class="r b data"&gt;396&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="branch"&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Tabulate: Table 1" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c header" scope="col"&gt;T1&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T3&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T3-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T3-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T3-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T3&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T3-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T3-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T3-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T3&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T3-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T3-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T3-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T3&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T3-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T3-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T3-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T5&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r b data"&gt;57&lt;/TD&gt;
&lt;TD class="r b data"&gt;35&lt;/TD&gt;
&lt;TD class="r b data"&gt;24&lt;/TD&gt;
&lt;TD class="r b data"&gt;8&lt;/TD&gt;
&lt;TD class="r b data"&gt;13&lt;/TD&gt;
&lt;TD class="r b data"&gt;18&lt;/TD&gt;
&lt;TD class="r b data"&gt;29&lt;/TD&gt;
&lt;TD class="r b data"&gt;13&lt;/TD&gt;
&lt;TD class="r b data"&gt;23&lt;/TD&gt;
&lt;TD class="r b data"&gt;45&lt;/TD&gt;
&lt;TD class="r b data"&gt;19&lt;/TD&gt;
&lt;TD class="r b data"&gt;20&lt;/TD&gt;
&lt;TD class="r b data"&gt;15&lt;/TD&gt;
&lt;TD class="r b data"&gt;30&lt;/TD&gt;
&lt;TD class="r b data"&gt;19&lt;/TD&gt;
&lt;TD class="r b data"&gt;37&lt;/TD&gt;
&lt;TD class="r b data"&gt;61&lt;/TD&gt;
&lt;TD class="r b data"&gt;25&lt;/TD&gt;
&lt;TD class="r b data"&gt;23&lt;/TD&gt;
&lt;TD class="r b data"&gt;20&lt;/TD&gt;
&lt;TD class="r b data"&gt;20&lt;/TD&gt;
&lt;TD class="r b data"&gt;24&lt;/TD&gt;
&lt;TD class="r b data"&gt;26&lt;/TD&gt;
&lt;TD class="r b data"&gt;27&lt;/TD&gt;
&lt;TD class="r b data"&gt;54&lt;/TD&gt;
&lt;TD class="r b data"&gt;32&lt;/TD&gt;
&lt;TD class="r b data"&gt;26&lt;/TD&gt;
&lt;TD class="r b data"&gt;35&lt;/TD&gt;
&lt;TD class="r b data"&gt;53&lt;/TD&gt;
&lt;TD class="r b data"&gt;41&lt;/TD&gt;
&lt;TD class="r b data"&gt;43&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="branch"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 00:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600219#M173430</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-10-30T00:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Summary report of duplicate values from multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600228#M173436</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt; I was thinking of something like this:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This does not answer the question.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You have a multidimensional&amp;nbsp;crossing. How do you want to show it?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;'s solution give you a summarised overview (WANT2 below).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You could&amp;nbsp;also want a detailed&amp;nbsp;&lt;/SPAN&gt;overview (WANT1 below).&lt;/P&gt;
&lt;P&gt;Or anything in between.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data T1 T2 T3 T4 T5;
  do I=1 to 1000;
    if ranuni(0)&amp;gt;.6 then output T1;   
    if ranuni(0)&amp;gt;.6 then output T2;   
    if ranuni(0)&amp;gt;.6 then output T3;   
    if ranuni(0)&amp;gt;.6 then output T4;   
    if ranuni(0)&amp;gt;.6 then output T5;
  end;
run;

data WANT1;
  merge T1(in=A) T2(in=B) T3(in=C) T4(in=D) T5(in=E);
  by I;
  src=catx('-',ifc(A,'T1',''),ifc(B,'T2',''),ifc(C,'T3',''),ifc(D,'T4',''),ifc(E,'T5',''));
run;

proc tabulate data=WANT1;
  class SRC;
  table src=' '*n=' '; 
run;

data WANT2 (keep=ROW COL );
  length ROW COL $4;
  merge T1(in=A) T2(in=B) T3(in=C) T4(in=D) T5(in=E);
  by I;
  array _in {5} in1-in5;
  do C=1 to 5;
    COL=cats('SET',C);
    if _in{C}=1 then do R=C to 5;
      ROW=cats('SET',R);
      if _in{r}=1 then output;
    end;
  end;
run;

proc tabulate data=WANT2  noseps;
  class ROW  COL;
  table ROW=' ' , COL=' '*n=' ';
run;&lt;/CODE&gt;&lt;A target="_blank" name="IDX"&gt;&lt;/A&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Tabulate: Table 1" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;SET1&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;SET2&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;SET3&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;SET4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;SET5&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;SET1&lt;/TH&gt;
&lt;TD class="r b data"&gt;405&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;SET2&lt;/TH&gt;
&lt;TD class="r b data"&gt;163&lt;/TD&gt;
&lt;TD class="r b data"&gt;389&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;SET3&lt;/TH&gt;
&lt;TD class="r b data"&gt;162&lt;/TD&gt;
&lt;TD class="r b data"&gt;151&lt;/TD&gt;
&lt;TD class="r b data"&gt;397&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;SET4&lt;/TH&gt;
&lt;TD class="r b data"&gt;151&lt;/TD&gt;
&lt;TD class="r b data"&gt;156&lt;/TD&gt;
&lt;TD class="r b data"&gt;161&lt;/TD&gt;
&lt;TD class="r b data"&gt;396&lt;/TD&gt;
&lt;TD class="r b data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;SET5&lt;/TH&gt;
&lt;TD class="r b data"&gt;158&lt;/TD&gt;
&lt;TD class="r b data"&gt;160&lt;/TD&gt;
&lt;TD class="r b data"&gt;167&lt;/TD&gt;
&lt;TD class="r b data"&gt;178&lt;/TD&gt;
&lt;TD class="r b data"&gt;396&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="branch"&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Tabulate: Table 1" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c header" scope="col"&gt;T1&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T3&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T3-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T3-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T3-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T2-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T3&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T3-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T3-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T3-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T1-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T3&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T3-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T3-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T3-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T2-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T3&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T3-T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T3-T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T3-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T4&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T4-T5&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;T5&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r b data"&gt;57&lt;/TD&gt;
&lt;TD class="r b data"&gt;35&lt;/TD&gt;
&lt;TD class="r b data"&gt;24&lt;/TD&gt;
&lt;TD class="r b data"&gt;8&lt;/TD&gt;
&lt;TD class="r b data"&gt;13&lt;/TD&gt;
&lt;TD class="r b data"&gt;18&lt;/TD&gt;
&lt;TD class="r b data"&gt;29&lt;/TD&gt;
&lt;TD class="r b data"&gt;13&lt;/TD&gt;
&lt;TD class="r b data"&gt;23&lt;/TD&gt;
&lt;TD class="r b data"&gt;45&lt;/TD&gt;
&lt;TD class="r b data"&gt;19&lt;/TD&gt;
&lt;TD class="r b data"&gt;20&lt;/TD&gt;
&lt;TD class="r b data"&gt;15&lt;/TD&gt;
&lt;TD class="r b data"&gt;30&lt;/TD&gt;
&lt;TD class="r b data"&gt;19&lt;/TD&gt;
&lt;TD class="r b data"&gt;37&lt;/TD&gt;
&lt;TD class="r b data"&gt;61&lt;/TD&gt;
&lt;TD class="r b data"&gt;25&lt;/TD&gt;
&lt;TD class="r b data"&gt;23&lt;/TD&gt;
&lt;TD class="r b data"&gt;20&lt;/TD&gt;
&lt;TD class="r b data"&gt;20&lt;/TD&gt;
&lt;TD class="r b data"&gt;24&lt;/TD&gt;
&lt;TD class="r b data"&gt;26&lt;/TD&gt;
&lt;TD class="r b data"&gt;27&lt;/TD&gt;
&lt;TD class="r b data"&gt;54&lt;/TD&gt;
&lt;TD class="r b data"&gt;32&lt;/TD&gt;
&lt;TD class="r b data"&gt;26&lt;/TD&gt;
&lt;TD class="r b data"&gt;35&lt;/TD&gt;
&lt;TD class="r b data"&gt;53&lt;/TD&gt;
&lt;TD class="r b data"&gt;41&lt;/TD&gt;
&lt;TD class="r b data"&gt;43&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="branch"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will try this tomorrow morning. To be honest, I do not understand some lines of the code. However, this is amazing and it's way better that I wanted.&lt;/P&gt;
&lt;P&gt;I will deeply look into it to at least understand a small part of it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT:&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tried WANT1 and it works perfectly, thanks to you. However, for WANT2, it doesn't seem to works. It gives me an empty dataset with the two variables (ROW COL)...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 14:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600228#M173436</guid>
      <dc:creator>jpprovost</dc:creator>
      <dc:date>2019-10-30T14:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Summary report of duplicate values from multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600229#M173437</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&lt;BR /&gt;Thanks also for your help. Will try it tomorrow.</description>
      <pubDate>Wed, 30 Oct 2019 01:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600229#M173437</guid>
      <dc:creator>jpprovost</dc:creator>
      <dc:date>2019-10-30T01:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Summary report of duplicate values from multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600230#M173438</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&lt;BR /&gt;Thank you also for your time and help. I will try your piece of code also tomorrow.&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 30 Oct 2019 01:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600230#M173438</guid>
      <dc:creator>jpprovost</dc:creator>
      <dc:date>2019-10-30T01:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Summary report of duplicate values from multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600368#M173522</link>
      <description>&lt;P&gt;EDITED.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data T1 T2 T3 T4 T5;
  do I=1 to 1000;
    if ranuni(0)&amp;gt;.6 then output T1;   
    if ranuni(0)&amp;gt;.6 then output T2;   
    if ranuni(0)&amp;gt;.6 then output T3;   
    if ranuni(0)&amp;gt;.6 then output T4;   
    if ranuni(0)&amp;gt;.6 then output T5;
  end;
run;

%macro intersect(list= T1 T2 T3 T4 T5  );
%let n=%sysfunc(countw(&amp;amp;list , %str( ) ));

proc sql;
create table temp as

%do i=1 %to &amp;amp;n ;
%let a=%scan(&amp;amp;list,&amp;amp;i,%str( ));
%do j=1 %to &amp;amp;n ;
%let b=%scan(&amp;amp;list,&amp;amp;j,%str( ));

select "&amp;amp;a" as dsn1 length=40,"&amp;amp;b" as dsn2 length=40,count(*) as n from(
select * from &amp;amp;a 
intersect
select * from &amp;amp;b 
)

%if &amp;amp;i ne &amp;amp;n or &amp;amp;j ne &amp;amp;n %then %do; union %end;

%end;
%end;

;quit;

%mend;

options mprint mlogic symbolgen;
%intersect()

proc transpose data=temp out=want(drop=_:);
by dsn1;
id dsn2;
var n;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Oct 2019 13:31:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-report-of-duplicate-values-from-multiple-tables/m-p/600368#M173522</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-10-30T13:31:35Z</dc:date>
    </item>
  </channel>
</rss>

