<?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 can i compare two variables from different data sets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378057#M90822</link>
    <description>&lt;P&gt;OK, I think proc compare is a better result, because it gives me a summary report. also, by using sql i can get the details. Thank you all very much.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jul 2017 10:09:07 GMT</pubDate>
    <dc:creator>lixuan</dc:creator>
    <dc:date>2017-07-21T10:09:07Z</dc:date>
    <item>
      <title>How can i compare two variables from different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378024#M90812</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi, Maybe &amp;nbsp;a very simple quesion, but it puzzles me. I want to compare two variables with different names in two data sets. How can I do it? for example, I want to compare a in data set one with d in data set two. I check the 'proc compare', but it compares the whole data set. thank you .&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input a
cards;
6
5
6
7
;
run;
data two;
input d;
cards;
7
8
5
2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 08:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378024#M90812</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-07-21T08:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can i compare two variables from different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378026#M90813</link>
      <description>&lt;P&gt;What do you mean by compare? Do you want to subtract them from each other? And do you not have some ID variable, this will usually be the case when comparing variables.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 09:02:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378026#M90813</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-07-21T09:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can i compare two variables from different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378029#M90814</link>
      <description>&lt;P&gt;No , &amp;nbsp;I just want to compare the two variables to identify if they can be used as ID &amp;nbsp;which can be used to merge the two data sets.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 09:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378029#M90814</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-07-21T09:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can i compare two variables from different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378030#M90815</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;&amp;nbsp;I want to compare two variables with different names in two data sets." - I am sorry, could you explain what you mean/want as output? &amp;nbsp;You say you don't want to compare the whole dataset, so what exactly is it you want to compare? &amp;nbsp;Proc compare would obviously be first choice, just rename d to a:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;proc compare base=one compare=two (rename=(d=a));
run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 09:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378030#M90815</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-21T09:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can i compare two variables from different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378033#M90816</link>
      <description>&lt;P&gt;What is the meaning of those two variables? What output you want to get?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You said that:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;I check the 'proc compare', but it compares the whole data set.&lt;/PRE&gt;
&lt;P&gt;you can use proc compare as:&lt;/P&gt;
&lt;PRE&gt;proc compare base=one (keep=a)
               compare=two(keep=d rename=(d=a));
run;&lt;/PRE&gt;
&lt;P&gt;If it doesn't satisfy you, explain why and what are you expecting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Besides you wrote:&lt;/P&gt;
&lt;PRE&gt; I just want to compare the two variables to identify if they can be used as ID  &lt;/PRE&gt;
&lt;P&gt;should't the IDs be unique? How do you know when they fit that they have same meaning and can be used as IDs ?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 09:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378033#M90816</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-21T09:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can i compare two variables from different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378034#M90817</link>
      <description>&lt;P&gt;Sure , I have two datasets with different variables, and I want to merge both, but I dont konw which variables can be use as ID, so i want to compare the variables.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 09:22:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378034#M90817</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-07-21T09:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: How can i compare two variables from different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378037#M90818</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test as
select t1.a, t2.d
from one t1 full join two t2
on t1.a = t2.d
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will give you a picture how the variables match.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 09:31:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378037#M90818</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-21T09:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: How can i compare two variables from different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378057#M90822</link>
      <description>&lt;P&gt;OK, I think proc compare is a better result, because it gives me a summary report. also, by using sql i can get the details. Thank you all very much.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 10:09:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378057#M90822</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-07-21T10:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can i compare two variables from different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378059#M90823</link>
      <description>&lt;P&gt;Your code is helpful. The ID should be unique. I am merging different stock data, but different database has their own ID system, so i want to know if they are same. Thks$ regards&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 10:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378059#M90823</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-07-21T10:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can i compare two variables from different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378207#M90856</link>
      <description>&lt;P&gt;You didn't show the Proc Compare code you used. If the variables are different names in the two sets you can use something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc compare base=one compare=two;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var a;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; with d;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to restrict the comparison to specific variables and only compare the ones of interest.&lt;/P&gt;
&lt;P&gt;Since you looking a suitability as a matching variable you might want to sort the data sets by the candidate variable for better results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 15:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378207#M90856</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-21T15:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can i compare two variables from different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378209#M90857</link>
      <description>Thank you , I don't konw proc compare code can be folllowed by var. yours answer is the simpliest.</description>
      <pubDate>Fri, 21 Jul 2017 15:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-compare-two-variables-from-different-data-sets/m-p/378209#M90857</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-07-21T15:44:46Z</dc:date>
    </item>
  </channel>
</rss>

