<?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 output observations in one dataset but not in another in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/output-observations-in-one-dataset-but-not-in-another/m-p/937001#M368202</link>
    <description>&lt;P&gt;I am using Proc Compare to try and select the observations in one dataset, but not in the other, and output the observations.&amp;nbsp; There does not seem to be an out=&amp;nbsp; &amp;nbsp;option that does this ?&amp;nbsp; Please advise.&amp;nbsp; Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc contents data=work.import_163;&lt;BR /&gt;run;&lt;BR /&gt;*proc print;&lt;BR /&gt;*run;&lt;BR /&gt;proc sort data=work.import_163;&lt;BR /&gt;by Wrs_acres;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data Merge_148_163;&lt;BR /&gt;merge work.import_148 work.import_163 ;&lt;BR /&gt;by WRS_acres;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Proc print data=Merge_148_163;&lt;BR /&gt;run;&lt;BR /&gt;proc contents data=Merge_148_163;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc compare base=work.import_163 compare=work.import_148&lt;BR /&gt;out=diff outnoequal noprint;&lt;BR /&gt;id wrs_acres;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc print data=diff ;&lt;BR /&gt;by wrs_acres;&lt;BR /&gt;id wrs_acres;&lt;BR /&gt;title 'The Output Data Set RESULT';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jul 2024 15:10:47 GMT</pubDate>
    <dc:creator>Fluvio1</dc:creator>
    <dc:date>2024-07-24T15:10:47Z</dc:date>
    <item>
      <title>output observations in one dataset but not in another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-observations-in-one-dataset-but-not-in-another/m-p/937001#M368202</link>
      <description>&lt;P&gt;I am using Proc Compare to try and select the observations in one dataset, but not in the other, and output the observations.&amp;nbsp; There does not seem to be an out=&amp;nbsp; &amp;nbsp;option that does this ?&amp;nbsp; Please advise.&amp;nbsp; Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc contents data=work.import_163;&lt;BR /&gt;run;&lt;BR /&gt;*proc print;&lt;BR /&gt;*run;&lt;BR /&gt;proc sort data=work.import_163;&lt;BR /&gt;by Wrs_acres;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data Merge_148_163;&lt;BR /&gt;merge work.import_148 work.import_163 ;&lt;BR /&gt;by WRS_acres;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Proc print data=Merge_148_163;&lt;BR /&gt;run;&lt;BR /&gt;proc contents data=Merge_148_163;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc compare base=work.import_163 compare=work.import_148&lt;BR /&gt;out=diff outnoequal noprint;&lt;BR /&gt;id wrs_acres;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc print data=diff ;&lt;BR /&gt;by wrs_acres;&lt;BR /&gt;id wrs_acres;&lt;BR /&gt;title 'The Output Data Set RESULT';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 15:10:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-observations-in-one-dataset-but-not-in-another/m-p/937001#M368202</guid>
      <dc:creator>Fluvio1</dc:creator>
      <dc:date>2024-07-24T15:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: output observations in one dataset but not in another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-observations-in-one-dataset-but-not-in-another/m-p/937004#M368203</link>
      <description>&lt;P&gt;If you want to match the observations on the key variables then just use a data step to split the data into matching and non matching datasets.&lt;/P&gt;
&lt;P&gt;So something like this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data both left_only right_only;
  merge left(in=inleft) right(in=inright);
  by keys ;
  if inleft and inright then output both;
  else if inleft then output left_only;
  else output right_only;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want EXACT matches then make the BY statement include ALL of the variables.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 15:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-observations-in-one-dataset-but-not-in-another/m-p/937004#M368203</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-24T15:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: output observations in one dataset but not in another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-observations-in-one-dataset-but-not-in-another/m-p/937010#M368206</link>
      <description>&lt;P&gt;The options would be OUTBASE if you want the observation from the BASE data set or OUTCOMP if you want them from the COMPARE set.&lt;/P&gt;
&lt;P&gt;Note that a variable telling you which data set the observations come from is added:&lt;/P&gt;
&lt;PRE&gt;data work.base;
   set sashelp.class;
run;

data work.comp;
   set sashelp.class;
   if sex='M' and name not in ('Alfred' 'Robert')then height=height+1;
run;

proc compare base=work.base compare=work.comp noprint
   out=work.different outnoequal outcomp;
run;

proc compare base=work.base compare=work.comp noprint
   out=work.different2 outnoequal outbase;
run;&lt;/PRE&gt;
&lt;P&gt;You can run this as you should have the SASHELP.CLASS data set.&lt;/P&gt;
&lt;P&gt;Since you did not provide any actual data or what you want to see from the result it is hard to tell if this actually matches your expectations.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 15:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-observations-in-one-dataset-but-not-in-another/m-p/937010#M368206</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-24T15:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: output observations in one dataset but not in another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-observations-in-one-dataset-but-not-in-another/m-p/937113#M368220</link>
      <description>&lt;P&gt;I tried both programs but they do not provide the results I am looking for.&amp;nbsp; The attached dataset "Compare_dataset_148_obsv" contains 148 observations. The dataset "Compare_dataset_214_obsv" contains 214 observations.&amp;nbsp; I would like to identify the observations in&amp;nbsp;&amp;nbsp;"Compare_dataset_214_obsv" that are not in&amp;nbsp;&amp;nbsp;"Compare_dataset_148_obsv" and output the observations to a file.&amp;nbsp; While the datasets contain different variables, they have in common:&amp;nbsp; WRS_acres.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 14:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-observations-in-one-dataset-but-not-in-another/m-p/937113#M368220</guid>
      <dc:creator>Fluvio1</dc:creator>
      <dc:date>2024-07-25T14:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: output observations in one dataset but not in another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-observations-in-one-dataset-but-not-in-another/m-p/937116#M368221</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table data_want as 
select * from compare_dataset_214_obsv
where wrs_acres not in (select distinct wrs_acres from compare_dataset_148_obs);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/429285"&gt;@Fluvio1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried both programs but they do not provide the results I am looking for.&amp;nbsp; The attached dataset "Compare_dataset_148_obsv" contains 148 observations. The dataset "Compare_dataset_214_obsv" contains 214 observations.&amp;nbsp; I would like to identify the observations in&amp;nbsp;&amp;nbsp;"Compare_dataset_214_obsv" that are not in&amp;nbsp;&amp;nbsp;"Compare_dataset_148_obsv" and output the observations to a file.&amp;nbsp; While the datasets contain different variables, they have in common:&amp;nbsp; WRS_acres.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 14:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-observations-in-one-dataset-but-not-in-another/m-p/937116#M368221</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-07-25T14:39:35Z</dc:date>
    </item>
  </channel>
</rss>

