<?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 exclude the observations in both dataset A and B when they have matched with each other in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511531#M137670</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to exclude the observations in both dataset A and B when they have matched with each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example,&amp;nbsp;&lt;/P&gt;&lt;P&gt;in dataset&amp;nbsp;A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;name, number&amp;nbsp;&lt;/P&gt;&lt;P&gt;apple,10&lt;/P&gt;&lt;P&gt;pear,11&lt;/P&gt;&lt;P&gt;pen,12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in dataset B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;name, age&amp;nbsp;&lt;/P&gt;&lt;P&gt;apple,5&lt;/P&gt;&lt;P&gt;fight,19&lt;/P&gt;&lt;P&gt;air,7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a new dataset C, which includes&lt;/P&gt;&lt;P&gt;name, number, age&amp;nbsp;&lt;/P&gt;&lt;P&gt;apple,10,5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then exclude observations apple from dataset&amp;nbsp;B and C, like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataset B&lt;/P&gt;&lt;P&gt;name, number&lt;/P&gt;&lt;P&gt;pear,11&lt;/P&gt;&lt;P&gt;pen,12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataset C&lt;/P&gt;&lt;P&gt;name,&amp;nbsp;&lt;SPAN&gt;age&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;fight,19&lt;/P&gt;&lt;P&gt;air,7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please give me some suggestions about this.&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Nov 2018 20:41:16 GMT</pubDate>
    <dc:creator>France</dc:creator>
    <dc:date>2018-11-08T20:41:16Z</dc:date>
    <item>
      <title>exclude the observations in both dataset A and B when they have matched with each other</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511531#M137670</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to exclude the observations in both dataset A and B when they have matched with each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example,&amp;nbsp;&lt;/P&gt;&lt;P&gt;in dataset&amp;nbsp;A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;name, number&amp;nbsp;&lt;/P&gt;&lt;P&gt;apple,10&lt;/P&gt;&lt;P&gt;pear,11&lt;/P&gt;&lt;P&gt;pen,12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in dataset B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;name, age&amp;nbsp;&lt;/P&gt;&lt;P&gt;apple,5&lt;/P&gt;&lt;P&gt;fight,19&lt;/P&gt;&lt;P&gt;air,7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a new dataset C, which includes&lt;/P&gt;&lt;P&gt;name, number, age&amp;nbsp;&lt;/P&gt;&lt;P&gt;apple,10,5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then exclude observations apple from dataset&amp;nbsp;B and C, like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataset B&lt;/P&gt;&lt;P&gt;name, number&lt;/P&gt;&lt;P&gt;pear,11&lt;/P&gt;&lt;P&gt;pen,12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataset C&lt;/P&gt;&lt;P&gt;name,&amp;nbsp;&lt;SPAN&gt;age&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;fight,19&lt;/P&gt;&lt;P&gt;air,7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please give me some suggestions about this.&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 20:41:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511531#M137670</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-11-08T20:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: exclude the observations in both dataset A and B when they have matched with each other</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511532#M137671</link>
      <description>&lt;P&gt;Pear started off in data set A, how did it wind up in data set B?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 20:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511532#M137671</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-08T20:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: exclude the observations in both dataset A and B when they have matched with each other</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511533#M137672</link>
      <description>Can you have duplicates within a single file? If not, consider appending the data and using PROC SORT with the UNIQUEKEY and DUPOUT options.</description>
      <pubDate>Thu, 08 Nov 2018 20:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511533#M137672</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-08T20:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: exclude the observations in both dataset A and B when they have matched with each other</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511534#M137673</link>
      <description>&lt;P&gt;If I have understood your question correctly, you should get the datasets you want (a1, b1 and c) with the the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sort data=a;
 by name;
run;

proc sort data=b;
 by name;
run;

data a1 b1 c;
 merge a (in=a) b (in=b);
 by name;
 if a and not b then output a1;
 if b and not a then output b1;
 if a and b then output c;
run;

&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Nov 2018 20:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511534#M137673</guid>
      <dc:creator>AnnaHawgood</dc:creator>
      <dc:date>2018-11-08T20:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: exclude the observations in both dataset A and B when they have matched with each other</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511538#M137675</link>
      <description>&lt;P&gt;I think you start getting your data set names messed up a bit.&lt;/P&gt;
&lt;P&gt;This does what you ask, using different final data set names, for your example data.&lt;/P&gt;
&lt;PRE&gt;data a;
   infile datalines dlm=',';
   input name $ number ;
datalines;
apple,10
pear,11
pen,12
;
run;
 
data b;
   infile datalines dlm=',';
   input name $ age ;
datalines;
apple,5
fight,19
air,7
;
run;

proc sort data=a;
  by name;
run;

proc sort data=b;
  by name;
run;

data n1 n2 (drop=age) n3 (drop=number);
   merge a (in=ina)
         b( in=inb )
   ;
   by name;
   if ina and inb then output n1;
   else if ina then output n2;
   else if inb then output n3;
run;
&lt;/PRE&gt;
&lt;P&gt;BTW almost any operation that reads dataset named XXX and writes a modified version back to XXX is very dangerous as you replace the existing data set and lose the starting data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 21:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511538#M137675</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-08T21:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: exclude the observations in both dataset A and B when they have matched with each other</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511697#M137726</link>
      <description>Dear Reeza,&lt;BR /&gt;thanks for your advice. Could you please explain the meaning in detail for me? Especially, what is the meaning of 'duplicates within a single file' ?</description>
      <pubDate>Fri, 09 Nov 2018 14:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511697#M137726</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-11-09T14:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: exclude the observations in both dataset A and B when they have matched with each other</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511723#M137730</link>
      <description>&lt;P&gt;1. Append the files - use a data step with INDSNAME option to see the source input file.&lt;/P&gt;
&lt;P&gt;2. Read up on PROC SORT - specifcially UNIQUEKEY and NOUNIQUE&lt;/P&gt;
&lt;P&gt;3. Use those options to push the duplicate keys to one data set and the others to a different data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Dear Reeza,&lt;BR /&gt;thanks for your advice. Could you please explain the meaning in detail for me? Especially, what is the meaning of 'duplicates within a single file' ?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 15:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/511723#M137730</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-09T15:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: exclude the observations in both dataset A and B when they have matched with each other</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/512014#M137855</link>
      <description>&lt;P&gt;Dear ballardw,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your advice. I am using the following codes,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
data sa_step6.Distinct_name_ori1;
  set Result.Distinct_name;
  rename psn_name=name;
run;

proc sort data=step1.WSCOPEUK;
  by name;
run;

proc sort data=sa_step6.Distinct_name_ori1;
  by name;
run;

&lt;U&gt;data SA_STEP5.WSCOPEUK_TRY1 sa_step6.Distinct_name_ori2 sa_step6.WSCOPEUK_ori2 ;
   merge sa_step6.Distinct_name_ori1 (in=ina)
         step1.WSCOPEUK (in=ina)
   ;
   by name;
   if ina and inb then output SA_STEP5.WSCOPEUK_TRY1;
   else if ina then output sa_step6.Distinct_name_ori2;
   else if inb then output sa_step6.WSCOPEUK_ori2;
run;&lt;/U&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;however, I get the following result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;858
859  data sa_step6.Distinct_name_ori1;
860    set Result.Distinct_name;
861    rename psn_name=name;
862  run;

NOTE: There were 881490 observations read from the data set RESULT.DISTINCT_NAME.
NOTE: The data set SA_STEP6.DISTINCT_NAME_ORI1 has 881490 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           39.55 seconds
      cpu time            2.35 seconds


863
864  proc sort data=step1.WSCOPEUK;
865    by name;
866  run;

NOTE: Input data set is already sorted, no sorting done.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


867
868  proc sort data=sa_step6.Distinct_name_ori1;
869    by name;
870  run;

NOTE: There were 881490 observations read from the data set SA_STEP6.DISTINCT_NAME_ORI1.
NOTE: The data set SA_STEP6.DISTINCT_NAME_ORI1 has 881490 observations and 2 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           21.02 seconds
      cpu time            4.84 seconds


871
872  data SA_STEP5.WSCOPEUK_TRY1 sa_step6.Distinct_name_ori2 sa_step6.WSCOPEUK_ori2 ;
873     merge sa_step6.Distinct_name_ori1 (in=ina)
874           step1.WSCOPEUK (in=ina)
875     ;
876     by name;
877     if ina and inb then output SA_STEP5.WSCOPEUK_TRY1;
878     else if ina then output sa_step6.Distinct_name_ori2;
879     else if inb then output sa_step6.WSCOPEUK_ori2;
880  run;

NOTE: Variable inb is uninitialized.
NOTE: MERGE statement has more than one data set with repeats of BY values.
NOTE: There were 881490 observations read from the data set SA_STEP6.DISTINCT_NAME_ORI1.
NOTE: There were 5664 observations read from the data set STEP1.WSCOPEUK.
NOTE: The data set SA_STEP5.WSCOPEUK_TRY1 has 0 observations and 15 variables.
NOTE: The data set SA_STEP6.DISTINCT_NAME_ORI2 has 887001 observations and 15 variables.
NOTE: The data set SA_STEP6.WSCOPEUK_ORI2 has 0 observations and 15 variables.
NOTE: DATA statement used (Total process time):
      real time           35.96 seconds
      cpu time            2.79 seconds


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;could you please give me some suggestion to fix this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advanece&lt;/P&gt;</description>
      <pubDate>Sun, 11 Nov 2018 17:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/512014#M137855</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-11-11T17:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: exclude the observations in both dataset A and B when they have matched with each other</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/512023#M137864</link>
      <description>&lt;P&gt;You used in=ina for both your data sets on the merge statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   merge sa_step6.Distinct_name_ori1 (in=ina)
         step1.WSCOPEUK (in=ina)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Change&amp;nbsp;one of them to inb.&amp;nbsp; I can't say at a glance which one&amp;nbsp; you want to be inb.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's why you have the note in the log that inb is uninitialized.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Nov 2018 18:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-the-observations-in-both-dataset-A-and-B-when-they-have/m-p/512023#M137864</guid>
      <dc:creator>SuzanneDorinski</dc:creator>
      <dc:date>2018-11-11T18:32:34Z</dc:date>
    </item>
  </channel>
</rss>

