<?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 output 2 the comparision of 2 fields from 2 different tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-2-the-comparision-of-2-fields-from-2-different/m-p/726933#M225972</link>
    <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to compare if 2 fields from 2 different tables are the same or at least, see how much the difference is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have var "price1" from table1 and var "price2" from table2. Both tables in the same library.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I print the comparision between price1 and price2 in one only output like this:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;price1&lt;/TD&gt;&lt;TD&gt;price2&lt;/TD&gt;&lt;TD&gt;difference&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 16 Mar 2021 23:12:06 GMT</pubDate>
    <dc:creator>clipsia</dc:creator>
    <dc:date>2021-03-16T23:12:06Z</dc:date>
    <item>
      <title>how to output 2 the comparision of 2 fields from 2 different tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-2-the-comparision-of-2-fields-from-2-different/m-p/726933#M225972</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to compare if 2 fields from 2 different tables are the same or at least, see how much the difference is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have var "price1" from table1 and var "price2" from table2. Both tables in the same library.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I print the comparision between price1 and price2 in one only output like this:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;price1&lt;/TD&gt;&lt;TD&gt;price2&lt;/TD&gt;&lt;TD&gt;difference&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 23:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-output-2-the-comparision-of-2-fields-from-2-different/m-p/726933#M225972</guid>
      <dc:creator>clipsia</dc:creator>
      <dc:date>2021-03-16T23:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to output 2 the comparision of 2 fields from 2 different tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-2-the-comparision-of-2-fields-from-2-different/m-p/726934#M225973</link>
      <description>&lt;P&gt;Combine the data into one data set then do the comparison.&lt;/P&gt;
&lt;P&gt;If there is a variable or combination of variables to match the two on that makes more sense.&lt;/P&gt;
&lt;PRE&gt;data one;
  input id price1;
datalines;
1  4
2  5
3  77
;

data two;
  input id price5;
datalines;
1 1
2 15
3 12
;

data want;
   merge one two;
   by id;
   difference = price1 - price5;
run;

proc print data=want;
   var price1 price5 difference;
run;&lt;/PRE&gt;
&lt;P&gt;If you only have one record then the merge still works. If there are multiple records and you want to match them on a variable(or more) then sort by the matching variable prior to the data step with the merge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are other ways possible as well. Example data of more complex problems would be needed for any solution.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 23:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-output-2-the-comparision-of-2-fields-from-2-different/m-p/726934#M225973</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-16T23:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to output 2 the comparision of 2 fields from 2 different tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-2-the-comparision-of-2-fields-from-2-different/m-p/726939#M225976</link>
      <description>&lt;P&gt;sorry but Im talking about huge tables.&lt;/P&gt;&lt;P&gt;I just need sum(price1) because is the total sum of the variable that Im comparing&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 23:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-output-2-the-comparision-of-2-fields-from-2-different/m-p/726939#M225976</guid>
      <dc:creator>clipsia</dc:creator>
      <dc:date>2021-03-16T23:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to output 2 the comparision of 2 fields from 2 different tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-2-the-comparision-of-2-fields-from-2-different/m-p/726955#M225985</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355077"&gt;@clipsia&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;sorry but Im talking about huge tables.&lt;/P&gt;
&lt;P&gt;I just need sum(price1) because is the total sum of the variable that Im comparing&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then you summarize the data with a procedure like Proc Means or summary, then combine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc summary data=have;
   var price1;
   output out=work.price1sum  sum=;
run;&lt;/PRE&gt;
&lt;P&gt;will create a data set with the sum or Price1 (and couple of other variables you can ignore for the moment).&lt;/P&gt;
&lt;P&gt;Do the same with the other data set. Then combine.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 01:21:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-output-2-the-comparision-of-2-fields-from-2-different/m-p/726955#M225985</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-17T01:21:25Z</dc:date>
    </item>
  </channel>
</rss>

