<?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: Variable comparison in two different datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-comparison-in-two-different-datasets/m-p/882079#M348512</link>
    <description>&lt;P&gt;proc compare check on observation level meaning check osb 1 from clm is equal to obs 1 from gsl. I unterstand your task is to catch observations which have no match in the opposite table. So my solution is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sort data = clm;
	by counterparty;
run;

proc sort data = gsl;
	by splr_name;
run;

data 	clm_only (rename =(joinvar = counterparty ) drop = relid phn)
	gsl_only (rename =(joinvar = splr_name ) drop = id name);
merge   clm (in =inclm rename =(counterparty = joinvar))
	gsl (in =ingsl rename =(splr_name = joinvar));
by joinvar;
if ingsl eq 0 then output clm_only;
if inclm eq 0 then output gsl_only;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Jun 2023 07:46:42 GMT</pubDate>
    <dc:creator>HenryKobus</dc:creator>
    <dc:date>2023-06-23T07:46:42Z</dc:date>
    <item>
      <title>Variable comparison in two different datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-comparison-in-two-different-datasets/m-p/882075#M348509</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have two completely different datasets.&lt;/P&gt;&lt;P&gt;Dataset1 -clm has variables counterparty,id,name&lt;/P&gt;&lt;P&gt;Dataset2-gsl has variable splr_name,relid,phn&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I need to compare the counterparty name in clm and splr_name in gsl in&amp;nbsp;&lt;/P&gt;&lt;P&gt;New dataset and report the not matching ones.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please help me on this.&lt;/P&gt;&lt;P&gt;Can I simply use proc compare or is there any other way .&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 06:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-comparison-in-two-different-datasets/m-p/882075#M348509</guid>
      <dc:creator>Akshaya_1397</dc:creator>
      <dc:date>2023-06-23T06:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Variable comparison in two different datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-comparison-in-two-different-datasets/m-p/882079#M348512</link>
      <description>&lt;P&gt;proc compare check on observation level meaning check osb 1 from clm is equal to obs 1 from gsl. I unterstand your task is to catch observations which have no match in the opposite table. So my solution is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sort data = clm;
	by counterparty;
run;

proc sort data = gsl;
	by splr_name;
run;

data 	clm_only (rename =(joinvar = counterparty ) drop = relid phn)
	gsl_only (rename =(joinvar = splr_name ) drop = id name);
merge   clm (in =inclm rename =(counterparty = joinvar))
	gsl (in =ingsl rename =(splr_name = joinvar));
by joinvar;
if ingsl eq 0 then output clm_only;
if inclm eq 0 then output gsl_only;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Jun 2023 07:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-comparison-in-two-different-datasets/m-p/882079#M348512</guid>
      <dc:creator>HenryKobus</dc:creator>
      <dc:date>2023-06-23T07:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Variable comparison in two different datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-comparison-in-two-different-datasets/m-p/882107#M348516</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/425756"&gt;@Akshaya_1397&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have two completely different datasets.&lt;/P&gt;
&lt;P&gt;Dataset1 -clm has variables counterparty,id,name&lt;/P&gt;
&lt;P&gt;Dataset2-gsl has variable splr_name,relid,phn&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I need to compare the counterparty name in clm and splr_name in gsl in&amp;nbsp;&lt;/P&gt;
&lt;P&gt;New dataset and report the not matching ones.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone please help me on this.&lt;/P&gt;
&lt;P&gt;Can I simply use proc compare or is there any other way .&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is not clear what you mean by "compare" and "not matching". Proc Compare is a observation by observation comparison by default. So is likely not the tool unless the data sets are expected to have the same number (or at least pretty close) of observations with similar values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do want just properties of the variables such as length, format and label?&lt;/P&gt;
&lt;P&gt;Or values that appear in one data set but not the other? This code will create two data sets with one observation of each value that appears in one data set but not the other. I think the names of the sets explain the contents. Obviously untested as we do not have your data sets.&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table in_clm_not_gsl as
   select distinct counterparty as value from clm
   except
   select distinct splr_name as value from gsl
   ;
   create table in_gsl_not_clm as
   select distinct splr_name as value from gsl
   except
   select distinct counterparty as value from clm
   ;
quit;
&lt;/PRE&gt;
&lt;P&gt;Warning: These are equal comparisons. So if your variable is character case differences will be reported as "BOB" is not the same as "Bob".&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 10:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-comparison-in-two-different-datasets/m-p/882107#M348516</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-23T10:05:02Z</dc:date>
    </item>
  </channel>
</rss>

