<?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 identify unique reords in two data sets in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359784#M23673</link>
    <description>&lt;P&gt;I am matching on id, for simplicity just listing two countries would prefer not to match on country as I would need to clean up spelling and abbreviations accoss the tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I do not need in the output I can use other variables that are unique to each table&amp;nbsp;for filtering.&lt;/P&gt;&lt;P&gt;Division(int) for data one, and&amp;nbsp;Risk_Profile $ for data two.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tried various combinations of is not missing, in a list etc. using the unique variables without success.&lt;/P&gt;</description>
    <pubDate>Thu, 18 May 2017 19:46:09 GMT</pubDate>
    <dc:creator>RickyS</dc:creator>
    <dc:date>2017-05-18T19:46:09Z</dc:date>
    <item>
      <title>How to identify unique records in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359770#M23671</link>
      <description>&lt;P&gt;Would like to do this in SAS EG 6.1 Query builder but if Proc SQL or BASE SAS makes more sense, I'll go in either direction.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two datasets:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input id&amp;nbsp;country $ revenue commission;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 Germany 500 100&lt;/P&gt;&lt;P&gt;2 Germany 500 100&lt;/P&gt;&lt;P&gt;4 Germany 500 100&lt;/P&gt;&lt;P&gt;9 Germany 500 100&lt;/P&gt;&lt;P&gt;11 Mexico 500 100&lt;/P&gt;&lt;P&gt;12 Mexico 500 100&lt;/P&gt;&lt;P&gt;14 Mexico 500 100&lt;/P&gt;&lt;P&gt;17 Mexico 500 100&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data two;&lt;/P&gt;&lt;P&gt;input id&amp;nbsp;country $ revenue commission;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;2 Germany 500 100&lt;/P&gt;&lt;P&gt;3&amp;nbsp;Germany 500 100&lt;/P&gt;&lt;P&gt;4 Germany 500 100&lt;/P&gt;&lt;P&gt;9 Germany 500 100&lt;/P&gt;&lt;P&gt;11 Mexico 500 100&lt;/P&gt;&lt;P&gt;13 Mexico 500 100&lt;/P&gt;&lt;P&gt;15 Mexico 500 100&lt;/P&gt;&lt;P&gt;17 Mexico 500 100&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected Output&lt;/P&gt;&lt;P&gt;1&amp;nbsp;Germany 500 100&lt;/P&gt;&lt;P&gt;3&amp;nbsp;Germany 500 100&lt;/P&gt;&lt;P&gt;12 Mexico 500 100&lt;/P&gt;&lt;P&gt;13 Mexico 500 100&lt;/P&gt;&lt;P&gt;14 Mexico 500 100&lt;/P&gt;&lt;P&gt;15 Mexico 500 100&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have tried various combinations of inner and left joins with new variables added without success, any help is much appreciated&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 19:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359770#M23671</guid>
      <dc:creator>RickyS</dc:creator>
      <dc:date>2017-05-18T19:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique reords in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359777#M23672</link>
      <description>&lt;P&gt;Questions to get started ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(1) Are you matching on ID and COUNTRY only, or are you also matching on the last two variables as well?&amp;nbsp; (What if ID and COUNTRY match, but REVENUE doesn't?&amp;nbsp; Would that be part of the output?)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(2) Why is 14 Mexico not part of the expected output?&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 19:39:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359777#M23672</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-18T19:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique reords in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359784#M23673</link>
      <description>&lt;P&gt;I am matching on id, for simplicity just listing two countries would prefer not to match on country as I would need to clean up spelling and abbreviations accoss the tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I do not need in the output I can use other variables that are unique to each table&amp;nbsp;for filtering.&lt;/P&gt;&lt;P&gt;Division(int) for data one, and&amp;nbsp;Risk_Profile $ for data two.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tried various combinations of is not missing, in a list etc. using the unique variables without success.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 19:46:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359784#M23673</guid>
      <dc:creator>RickyS</dc:creator>
      <dc:date>2017-05-18T19:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique reords in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359785#M23674</link>
      <description>&lt;P&gt;sorry 14 Mexico 500 100 should be listed in expected output&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 19:46:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359785#M23674</guid>
      <dc:creator>RickyS</dc:creator>
      <dc:date>2017-05-18T19:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique reords in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359788#M23675</link>
      <description>&lt;P&gt;OK, here's a standard way to find mismatches.&amp;nbsp; It assumes your data sets are sorted by ID:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data mismatch;&lt;/P&gt;
&lt;P&gt;merge one (in=in1) two (in=in2);&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;if in1=0 or in2=0;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that this will find mismatches on ID.&amp;nbsp; However, it will not find disagreements (for example, same ID in both data sets, but COUNTRY is different).&amp;nbsp; That's a different issue entirely.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 19:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359788#M23675</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-18T19:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique reords in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359847#M23677</link>
      <description>&lt;P&gt;For clean data sorted by ID country this works pretty good:&lt;/P&gt;
&lt;PRE&gt;proc compare base=one compare=two out=comp outnoequal outbase outcomp  noprint ;
id id country;
run;&lt;/PRE&gt;
&lt;P&gt;But if your country variable has as much issue with correct values as you imply then how do we know not to consider these as "matches"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;11 Mexico 500 100&lt;/P&gt;
&lt;P&gt;11 Mecixo 500 100&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 23:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359847#M23677</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-18T23:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique reords in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359976#M23681</link>
      <description>&lt;P&gt;You raise a good point Ballard, the data is less than&amp;nbsp;perfect, what I can say for sure is the id is accurate in both data sets and will either match or not match,&amp;nbsp;this exercise is ultimately trying to verify the amount of $$$ variation when there is a match&amp;nbsp;and when there is a non match.&amp;nbsp; When there is a non match, identifying the unique data set of origination.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 13:56:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359976#M23681</guid>
      <dc:creator>RickyS</dc:creator>
      <dc:date>2017-05-19T13:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique records in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359977#M23682</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data one;
input id country $ revenue commission;
datalines;
1 Germany 500 100
2 Germany 500 100
4 Germany 500 100
9 Germany 500 100
11 Mexico 500 100
12 Mexico 500 100
14 Mexico 500 100
17 Mexico 500 100
run;
 
data two;
input id country $ revenue commission;
datalines;
2 Germany 500 100
3 Germany 500 100
4 Germany 500 100
9 Germany 500 100
11 Mexico 500 100
13 Mexico 500 100
15 Mexico 500 100
17 Mexico 500 100
run;

proc sql;
(
select *
 from one
except
select *
 from two
)
 
union

(
select *
 from two
except
select *
 from one
)
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 May 2017 13:59:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359977#M23682</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-19T13:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique records in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359990#M23686</link>
      <description>&lt;P&gt;Thinking this through in my head,&amp;nbsp;would need to standardize the&amp;nbsp;variables in the tables and labels for variables across the tables to do the&amp;nbsp;union based on wildcard or just select and standardize the variables I need.&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 14:30:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359990#M23686</guid>
      <dc:creator>RickyS</dc:creator>
      <dc:date>2017-05-19T14:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique records in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359994#M23688</link>
      <description>&lt;P&gt;You don't need standardize variable or the same variable name .&lt;/P&gt;
&lt;P&gt;Only need the the same position and same type variable.&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 14:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/359994#M23688</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-19T14:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique reords in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/533964#M32995</link>
      <description>&lt;P&gt;This worked like a charm for my problem. Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 15:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/533964#M32995</guid>
      <dc:creator>Abbie</dc:creator>
      <dc:date>2019-02-08T15:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique records in two data sets</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/534245#M33007</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67527"&gt;@RickyS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use UNION &lt;STRONG&gt;CORR&lt;/STRONG&gt;&amp;nbsp;then columns in your source tables don't need to be in the same order. All you need is to ensure that same named variable in different source tables are of the same data type (Char or Num).&lt;/P&gt;
&lt;P&gt;You can also use a SELECT *. The result will then contain all the variables which exist in all source tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And another nice feature of a SAS SQL UNION:&lt;/P&gt;
&lt;P&gt;If lengths for character variables in source tables differ then the resulting column will have the max length from all source tables (=no truncation or warning/error messages).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Feb 2019 02:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-identify-unique-records-in-two-data-sets/m-p/534245#M33007</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-02-10T02:06:04Z</dc:date>
    </item>
  </channel>
</rss>

