<?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: Identify the change in sas dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552217#M153502</link>
    <description>&lt;P&gt;You were&amp;nbsp; close but missing one of the records from the base table.&lt;/P&gt;&lt;P&gt;Just use IS instead of BY which gives you exactly what you have in your required output table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure what you mean by "&lt;SPAN&gt;I am interested only in specific value according to the ID value.&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please take a look at this paper on Proc compare for more info on the ID statement&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings10/149-2010.pdf" target="_blank" rel="noopener"&gt;http://support.sas.com/resources/papers/proceedings10/149-2010.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc compare base=Table2 compare=table1 out=output   outbase outnoequal   ;
id product;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture.JPG" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/28805iE224B5E8F5C5C70B/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Apr 2019 17:58:30 GMT</pubDate>
    <dc:creator>ghosh</dc:creator>
    <dc:date>2019-04-18T17:58:30Z</dc:date>
    <item>
      <title>Identify the change in sas dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552116#M153480</link>
      <description>&lt;P&gt;Note: I am working on a very huge dataset, records are in million so it is helpful if you can help with optimised query. May be not proc sql.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to compare two tables and create a table with the column where there is difference or new record inserted.&lt;/P&gt;&lt;P&gt;i.e. we have table 1&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Product&lt;/TD&gt;&lt;TD&gt;Division&lt;/TD&gt;&lt;TD&gt;Department&lt;/TD&gt;&lt;TD&gt;Category&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p1&lt;/TD&gt;&lt;TD&gt;d1&lt;/TD&gt;&lt;TD&gt;dep1&lt;/TD&gt;&lt;TD&gt;cat1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p2&lt;/TD&gt;&lt;TD&gt;d2&lt;/TD&gt;&lt;TD&gt;dep2&lt;/TD&gt;&lt;TD&gt;cat2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p3&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;dep3&lt;/TD&gt;&lt;TD&gt;cat3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p4&lt;/TD&gt;&lt;TD&gt;d4&lt;/TD&gt;&lt;TD&gt;dep4&lt;/TD&gt;&lt;TD&gt;cat4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p5&lt;/TD&gt;&lt;TD&gt;d5&lt;/TD&gt;&lt;TD&gt;dep5&lt;/TD&gt;&lt;TD&gt;cat5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Table1;

input product $ Division $ Department $ Category $;
datalines;
p1 d1 dep1 cat1
p2 d2 dep2 cat2
p3 d3 dep3 cat3
p4 d4 dep4 cat4
p5 d5 dep5 cat5
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and another table 2, highlighted is the difference from table 1&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Product&lt;/TD&gt;&lt;TD&gt;Division&lt;/TD&gt;&lt;TD&gt;Department&lt;/TD&gt;&lt;TD&gt;Category&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p1&lt;/TD&gt;&lt;TD&gt;d1&lt;/TD&gt;&lt;TD&gt;dep1&lt;/TD&gt;&lt;TD&gt;cat1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p2&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;d22&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;dep2&lt;/TD&gt;&lt;TD&gt;cat2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p3&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;dep3&lt;/TD&gt;&lt;TD&gt;cat3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p4&lt;/TD&gt;&lt;TD&gt;d4&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;dep44&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;cat4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p5&lt;/TD&gt;&lt;TD&gt;d5&lt;/TD&gt;&lt;TD&gt;dep5&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;cat55&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;p6&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;d6&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;dep6&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;cat56&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Table2;

input product $ Division $ Department $ Category $;
datalines;
p1 d1 dep1 cat1
p2 d22 dep2 cat2
p3 d3 dep3 cat3
p4 d4 dep44 cat4
p5 d5 dep5 cat55
p6 d6 dep6 cat56
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;we can see there is change (highlighted in red)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output should be the only changed record and new records&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Product&lt;/TD&gt;&lt;TD&gt;Division&lt;/TD&gt;&lt;TD&gt;Department&lt;/TD&gt;&lt;TD&gt;Category&lt;/TD&gt;&lt;TD&gt;Status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p2&lt;/TD&gt;&lt;TD&gt;d22&lt;/TD&gt;&lt;TD&gt;dep2&lt;/TD&gt;&lt;TD&gt;cat2&lt;/TD&gt;&lt;TD&gt;U&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p4&lt;/TD&gt;&lt;TD&gt;d4&lt;/TD&gt;&lt;TD&gt;dep44&lt;/TD&gt;&lt;TD&gt;cat4&lt;/TD&gt;&lt;TD&gt;U&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p5&lt;/TD&gt;&lt;TD&gt;d5&lt;/TD&gt;&lt;TD&gt;dep5&lt;/TD&gt;&lt;TD&gt;cat55&lt;/TD&gt;&lt;TD&gt;U&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;p6&lt;/TD&gt;&lt;TD&gt;d6&lt;/TD&gt;&lt;TD&gt;dep6&lt;/TD&gt;&lt;TD&gt;cat56&lt;/TD&gt;&lt;TD&gt;I&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data output;

input product $ Division $ Department $ Category $ Status $;
datalines;
p2 d22 dep2 cat2 U
p4 d4 dep44 cat4 U
p5 d5 dep5 cat55 U
p6 d6 dep6 cat56 I
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please help...&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 14:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552116#M153480</guid>
      <dc:creator>Srigyan</dc:creator>
      <dc:date>2019-04-18T14:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Identify the change in sas dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552129#M153483</link>
      <description>&lt;P&gt;Please show us what you have tried.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc compare has many options to show differences, that could be a starting point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 14:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552129#M153483</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2019-04-18T14:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Identify the change in sas dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552130#M153484</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200312"&gt;@Srigyan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Table1;

input product $ Division $ Department $ Category $;
datalines;
p1 d1 dep1 cat1
p2 d2 dep2 cat2
p3 d3 dep3 cat3
p4 d4 dep4 cat4
p5 d5 dep5 cat5
;
run;

data Table2;

input product $ Division $ Department $ Category $;
datalines;
p1 d1 dep1 cat1
p2 d22 dep2 cat2
p3 d3 dep3 cat3
p4 d4 dep44 cat4
p5 d5 dep5 cat55
p6 d6 dep6 cat56
;
run;

proc sql;
create table want as
(select *,'U' as status
from 
(select *
from table2 
where product in (select product from table1)
except 
select * from table1))
union 
(select *,'I' as status
from 
(select *
from table2
where product not in (select product from table1)));
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Apr 2019 14:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552130#M153484</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-18T14:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Identify the change in sas dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552142#M153490</link>
      <description>&lt;P&gt;Working fine now but I have two question&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) what this code is exactly doing, I see it giving me my answer but I could not understand the logic.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from 
(select * from table2 
where product in 
(select product from table1)
except 
select * from table1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2) My data is million in numbers and so is it better not to use proc sql or use any different method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 14:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552142#M153490</guid>
      <dc:creator>Srigyan</dc:creator>
      <dc:date>2019-04-18T14:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Identify the change in sas dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552148#M153493</link>
      <description>&lt;P&gt;Sure I agree that Proc sql may not be so robust if you dataset is humongous running into 100 million records or beyond. However , a few millions, I am pretty certain proc sql can comfortably handle.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The logic is all using SET operators. All you need to do is type sql set operators, you will find plethora of info.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An advantage of sql sometimes is&lt;/P&gt;
&lt;P&gt;1. You can push the query in-database level. So once you are connected to DB through sas access pass through, this sql is very advantageous&lt;/P&gt;
&lt;P&gt;2. Proc compare is good but sql gives better control.&lt;/P&gt;
&lt;P&gt;3. A datastep will likely require renaming and I was rather lazy in attempting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having said that, Feel free to wait for geniuses like &lt;STRONG&gt;Tom, PGstats, John King Datanull, Ballardw , Xia Keshan Ksharp , Reinhard, Patrick&lt;/STRONG&gt; etc to chime in with the solutions you prefer. If you can wait , you should be fine. I am awfully lazy rather for some weird reason they are always full of energy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 15:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552148#M153493</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-18T15:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Identify the change in sas dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552165#M153498</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc compare base=Table2 compare=table1 out=output outbase outnoequal   ;
by product;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This gives output fine but this gives the entire line, I am interested only in specific value according to the ID value. Here ID is the product.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 15:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552165#M153498</guid>
      <dc:creator>Srigyan</dc:creator>
      <dc:date>2019-04-18T15:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Identify the change in sas dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552217#M153502</link>
      <description>&lt;P&gt;You were&amp;nbsp; close but missing one of the records from the base table.&lt;/P&gt;&lt;P&gt;Just use IS instead of BY which gives you exactly what you have in your required output table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure what you mean by "&lt;SPAN&gt;I am interested only in specific value according to the ID value.&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please take a look at this paper on Proc compare for more info on the ID statement&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings10/149-2010.pdf" target="_blank" rel="noopener"&gt;http://support.sas.com/resources/papers/proceedings10/149-2010.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc compare base=Table2 compare=table1 out=output   outbase outnoequal   ;
id product;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture.JPG" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/28805iE224B5E8F5C5C70B/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 17:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-the-change-in-sas-dataset/m-p/552217#M153502</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2019-04-18T17:58:30Z</dc:date>
    </item>
  </channel>
</rss>

