<?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 How to compare one sas dataset with many sas datasets without proc compare. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610823#M177946</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for a logic where I can compare one source sas dataset with multiple destination sas datasets without proc compare. Also column names are different in the destination datasets.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 10 Dec 2019 20:32:58 GMT</pubDate>
    <dc:creator>abhityagi</dc:creator>
    <dc:date>2019-12-10T20:32:58Z</dc:date>
    <item>
      <title>How to compare one sas dataset with many sas datasets without proc compare.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610823#M177946</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for a logic where I can compare one source sas dataset with multiple destination sas datasets without proc compare. Also column names are different in the destination datasets.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 20:32:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610823#M177946</guid>
      <dc:creator>abhityagi</dc:creator>
      <dc:date>2019-12-10T20:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare one sas dataset with many sas datasets without proc compare.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610826#M177949</link>
      <description>Define compare.</description>
      <pubDate>Tue, 10 Dec 2019 20:56:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610826#M177949</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-10T20:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare one sas dataset with many sas datasets without proc compare.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610828#M177951</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is that you want to compare between both the dataset? Why not proc compare, doesn't it enough for your requirement. In that case you may have to write explicit code based on the data you have. Like SQL set operation with EXCEPT to find if same data exists in both the tables or other joins based on what you want to try.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the datasets are in different location, with dataset name being same, then you may first have to find the locations where dataset exist and then need to assign a LIBNAME. If you have only few locations then you can manually assign the libnames. If you have to automate instead of manually assigning then there are several scripts for searching the file name in a folder or sub-folders. This might help&amp;nbsp;&lt;A href="http://support.sas.com/kb/45/805.html" target="_blank"&gt;http://support.sas.com/kb/45/805.html&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 20:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610828#M177951</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2019-12-10T20:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare one sas dataset with many sas datasets without proc compare.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610837#M177958</link>
      <description>&lt;P&gt;For Example:&lt;/P&gt;&lt;P&gt;I have data set&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset1:&lt;/P&gt;&lt;P&gt;Columns: A B C D E F;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset2:&lt;/P&gt;&lt;P&gt;Columns: A B;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset 3:&lt;/P&gt;&lt;P&gt;Columns: C D;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset $:&lt;/P&gt;&lt;P&gt;Columns: E F;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here I want to data compare dataset1 with dataset2, 3 and dataset4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 21:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610837#M177958</guid>
      <dc:creator>abhityagi</dc:creator>
      <dc:date>2019-12-10T21:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare one sas dataset with many sas datasets without proc compare.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610842#M177962</link>
      <description>&lt;P&gt;Are you trying to find all tables that have columns that exist in one main table. Try joining dictionary.columns to find the tables that have similar columns.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table_abc;
a='';
b='';
c='';
run;

data table_a;
a='';
run;
data table_b;
b='';
run;
data table_c;
c='';
run;

proc sql;
create table test as 
select a.memname,a.name,b.memname as memname_c,b.name as name_c
from dictionary.columns as a
inner join dictionary.columns as b on a.name=b.name and a.memname&amp;lt;&amp;gt;b.memname
where a.libname='WORK' and a.memname='TABLE_ABC';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Dec 2019 21:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610842#M177962</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2019-12-10T21:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare one sas dataset with many sas datasets without proc compare.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610864#M177978</link>
      <description>&lt;P&gt;Here's one way:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/3b57ae085d9f7a36a2d95c15f04e72e6" target="_blank"&gt;https://gist.github.com/statgeek/3b57ae085d9f7a36a2d95c15f04e72e6&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Here's a bit of a long way to generate the list of datasets with variables present.
This program looks at ALL variables, to restrict it to a select list, see the line of 
code to be modified via the comments.;


    /*Generate fake data to work with*/
	data class1;
		set sashelp.class;
		drop age sex;
	run;
	
	data class2;
		set sashelp.class;
		drop weight height;
	run;
	
	data class3;
		set sashelp.class;
		Order=1;
	run;
	
	data class4;
		set sashelp.class;
		keep name;
	run;
	
	data class5;
		set sashelp.class;
	run;
	
    /*Extract metadata from dictionary tables*/
	proc sql noprint;
		create table column_list as select memname, libname, name, type, 1 as count 
			from dictionary.columns where libname='WORK' and memname like 'CLASS%'
			/*ADD THE VARIABLE LIST HERE*/
			order by memname, name;
	quit;
	
    /*Transpose results to a more user friendly format*/
	proc transpose data=column_list out=flipped;
		by memname;
		id name;
		idlabel name;
		var count;
	run;
	
    /*Format output*/
	data want;
		retain memname;
		set flipped;
		array class(*) _NUMERIC_;
	
		do i=1 to dim(class);
	
			if class(i)=. then
				class(i)=0;
		end;
		All_Variables=sum(of _numeric_)-I;
		DROP I _NAME_;
	run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138563"&gt;@abhityagi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;For Example:&lt;/P&gt;
&lt;P&gt;I have data set&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset1:&lt;/P&gt;
&lt;P&gt;Columns: A B C D E F;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset2:&lt;/P&gt;
&lt;P&gt;Columns: A B;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset 3:&lt;/P&gt;
&lt;P&gt;Columns: C D;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset $:&lt;/P&gt;
&lt;P&gt;Columns: E F;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here I want to data compare dataset1 with dataset2, 3 and dataset4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 22:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610864#M177978</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-10T22:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare one sas dataset with many sas datasets without proc compare.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610882#M177985</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138563"&gt;@abhityagi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;For Example:&lt;/P&gt;
&lt;P&gt;I have data set&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset1:&lt;/P&gt;
&lt;P&gt;Columns: A B C D E F;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset2:&lt;/P&gt;
&lt;P&gt;Columns: A B;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset 3:&lt;/P&gt;
&lt;P&gt;Columns: C D;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset $:&lt;/P&gt;
&lt;P&gt;Columns: E F;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here I want to data compare dataset1 with dataset2, 3 and dataset4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC COMPARE will handle this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data
   base
   comp1 (drop=name age)
   comp2 (drop=age sex)
   comp3 (drop=height weight)
   comp4 (drop=age sex weight)
   ;
   set sashelp.class;
run;

%macro comp(base=,comp=);
proc compare base=&amp;amp;base comp=&amp;amp;comp;
run;
%mend;
%comp(base=base,comp=comp1); 
%comp(base=base,comp=comp2); 
%comp(base=base,comp=comp3); 
%comp(base=base,comp=comp4); 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If this does not summarize your data requirements please provide more explanation.&amp;nbsp; Otherwise why reinvent the wheel?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 01:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-one-sas-dataset-with-many-sas-datasets-without/m-p/610882#M177985</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-12-11T01:45:08Z</dc:date>
    </item>
  </channel>
</rss>

