<?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: problem in deleting matching recoreds from two datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444681#M111371</link>
    <description>&lt;P&gt;Then your data doesn't look like what you have posted.&amp;nbsp; This could be for many reasons, could it be formatted to look like numbers?&amp;nbsp; Could it be numbers?&amp;nbsp; Could it have spaces or other special characters.&amp;nbsp; I can't tell you as I can't see your data.&amp;nbsp; Perhaps try following this and seeing what the data really look like:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Mar 2018 09:21:41 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-03-12T09:21:41Z</dc:date>
    <item>
      <title>problem in deleting matching recoreds from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444169#M111155</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am facing a problem in deleting matching observations in a dataset that are in match with another. I have used the below but they did not work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data set A:&lt;/P&gt;
&lt;P&gt;ID&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;Data set B&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;want data set C&lt;/P&gt;
&lt;P&gt;ID&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;/*************************************************/&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table&amp;nbsp;tableC as select a.* from &lt;BR /&gt;tableA&amp;nbsp;as a,&amp;nbsp;tableB as b where a.id^=b.id;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;/**************did not work***********************************/&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;/*************************************************/&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;BR /&gt; delete from work.tableA&lt;BR /&gt; where ID IN (select ID from work.tableB);&lt;BR /&gt; quit;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;/***************did not work**********************************/&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and I also tried deleting them directly&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;/*************************************************/&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;delete from tableA where ID in ("2","3");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;/*********************did not work****************************/&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I also tried atleast selecting the common Ids&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;select * from tableA where ID in ("2","3");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;this also did not work (but there are common IDs, I am sure. I dont understand the issue here. Please help. There are no errors in the log, the queries are just not deleting the common IDs.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards..&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 16:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444169#M111155</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-03-09T16:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: problem in deleting matching recoreds from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444171#M111156</link>
      <description>&lt;P&gt;Unfortunately "did not work" does not tell us anything.&amp;nbsp; If you data looks like that then:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table want as 
  select * 
  from   a
  except 
  select * 
  from   b;
quit;&lt;/PRE&gt;
&lt;P&gt;There are numerous other ways, merge by id if a and not b or b and not a for example in a datastep.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 16:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444171#M111156</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-09T16:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: problem in deleting matching recoreds from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444186#M111159</link>
      <description>&lt;P&gt;Hi RW9,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by "did not work" I mean, the queries that I mentioned above did not give the desired result.&lt;/P&gt;
&lt;P&gt;Those logics are not deleting the matching Ids the query runs and teh output dataset still contain sthe matching observations which should not be there. I suspect there is an internal format issue although the ID is in "char" in both the data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please advise, I cannot explain more because the query blindly does not work even though the logic is perfect. can this be some kind of technical issue?? if so, how can I resolve this..???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I mean a simple select * from tableA where ID in ("2","3") gives no result even though teh table has those Ids. What could be the reason for ths..?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 17:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444186#M111159</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-03-09T17:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: problem in deleting matching recoreds from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444193#M111161</link>
      <description>&lt;P&gt;you are almost there , you have to be very careful while writing any codes&lt;/P&gt;&lt;P&gt;for small doubts&amp;nbsp;you&amp;nbsp; should do trial and error until you get final Output but nevertheless&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here you go&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Data A;&lt;BR /&gt;input ID;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;Data B;&lt;BR /&gt;input ID;&lt;BR /&gt;datalines;&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table c as&lt;BR /&gt;select * From A&lt;BR /&gt;where id not in (select * from B);&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 17:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444193#M111161</guid>
      <dc:creator>Bhushan</dc:creator>
      <dc:date>2018-03-09T17:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: problem in deleting matching recoreds from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444202#M111165</link>
      <description>&lt;P&gt;This maybe because of leading or trailing blanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;" 1" is not equal to "1"&amp;nbsp;&lt;/P&gt;&lt;P&gt;check this query:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data TableA;
id=" 1";
run;
Data TableB;
id="1";
run;
proc sql;
create table tableC as 
select a.* from 
tableA as a, tableB as b where a.id^=b.id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Check with adding STRIP() Function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table tableC as 
select a.* from 
tableA as a, tableB as b where STRIP(a.id)^=STRIP(b.id);
quit;

proc sql;
delete from work.tableA
where STRIP(ID) IN (select STRIP(ID) from work.tableB);
quit;

proc sql;
delete from tableA where STRIP(ID) in ("2","3");
quit;

proc sql;
select * from tableA where STRIP(ID) in ("2","3");
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 18:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444202#M111165</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-03-09T18:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: problem in deleting matching recoreds from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444233#M111180</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51418"&gt;@don21&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi RW9,&lt;/P&gt;
&lt;P&gt;Please advise, I cannot explain more because the query blindly does not work even though the logic is perfect&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would suggest you consider restating "logic is perfect" as it that were the case the code would produce the desired results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Often "good code with wrong results" comes from an actual misunderstanding of the data contained such as assuming values are "identical" when they aren't. Character values are notorious for containing blanks or other not printable characters, tab or null for example, that you don't quite see in a casual look at data. Or you expect a word to be in consistent case such as "Male" but the data actually contains "male", "MALE" and "mALE" which would not match "Male. In SAS another issue can come from comparing numeric that use the same display format such a F5.2 and values appear to be the same when viewed with such but the internal values differ and hence are not equal.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 19:44:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444233#M111180</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-09T19:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: problem in deleting matching recoreds from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444681#M111371</link>
      <description>&lt;P&gt;Then your data doesn't look like what you have posted.&amp;nbsp; This could be for many reasons, could it be formatted to look like numbers?&amp;nbsp; Could it be numbers?&amp;nbsp; Could it have spaces or other special characters.&amp;nbsp; I can't tell you as I can't see your data.&amp;nbsp; Perhaps try following this and seeing what the data really look like:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 09:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444681#M111371</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-12T09:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: problem in deleting matching recoreds from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444684#M111373</link>
      <description>&lt;P&gt;The below code merge will work for ur problem :-&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;input num 3.;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data b;&lt;BR /&gt;input num 3.;&lt;BR /&gt;datalines;&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data c ;&lt;BR /&gt;merge a b ;&lt;BR /&gt;by num;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=c;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output :-&lt;/P&gt;&lt;P&gt;Obs num&lt;/P&gt;&lt;P&gt;1 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 09:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/444684#M111373</guid>
      <dc:creator>MG18</dc:creator>
      <dc:date>2018-03-12T09:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: problem in deleting matching recoreds from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/446761#M112146</link>
      <description>&lt;P&gt;Hi I have found teh root cause for my issue, it is nothing but both the ID columns which are currently in Char have been changed to Num and the code worked like charm.. I had the logics but was struggling due to this simple issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you all for the support!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 13:25:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-deleting-matching-recoreds-from-two-datasets/m-p/446761#M112146</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-03-19T13:25:43Z</dc:date>
    </item>
  </channel>
</rss>

