<?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: IF statement calling 2 datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-calling-2-datasets/m-p/718092#M222161</link>
    <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;FONT face="courier new,courier"&gt;data WANT;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; merge HAVE1 HAVE2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; by KEY;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; if NAME=LN;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Also, don't forget the account for when a variable is missing. For this use the IN= data set option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Feb 2021 01:53:25 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-02-10T01:53:25Z</dc:date>
    <item>
      <title>IF statement calling 2 datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-calling-2-datasets/m-p/718074#M222151</link>
      <description>&lt;P&gt;In SAS can we use IF statement which validates condition from two datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For eg. Dataset 'A' has Name, Age, Gender as variable and Dataset 'B' has LN variable.&lt;/P&gt;&lt;P&gt;I want to compare two datasets and delete all rows IF Names(from Dataset A) = LN&amp;nbsp; (from dataset B)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 00:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-calling-2-datasets/m-p/718074#M222151</guid>
      <dc:creator>pk10</dc:creator>
      <dc:date>2021-02-10T00:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement calling 2 datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-calling-2-datasets/m-p/718079#M222155</link>
      <description>&lt;P&gt;I think it's easy to merge using the in= dataset option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* sample datasets */
data a;
  set sashelp.class(keep=name age sex);
  rename sex=gender;
run;

data b;
  set sashelp.class(keep=name);
  rename name=ln;
  if _n_&amp;lt;10;
run;

/* merge with "in= dataset option" */
proc sort data=a;
  by name;
run;
proc sort data=b out=b(rename=(ln=name));/* need to rename as merge key */
  by ln;
run;

data c;
  merge a(in=inA) b(in=inB);
  if not(inA and inB);/* same as "if inA and inB then delete;" */
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or maybe you can use proc sql.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 00:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-calling-2-datasets/m-p/718079#M222155</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-02-10T00:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement calling 2 datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-calling-2-datasets/m-p/718092#M222161</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;FONT face="courier new,courier"&gt;data WANT;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; merge HAVE1 HAVE2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; by KEY;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; if NAME=LN;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Also, don't forget the account for when a variable is missing. For this use the IN= data set option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 01:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-calling-2-datasets/m-p/718092#M222161</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-02-10T01:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement calling 2 datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-calling-2-datasets/m-p/718196#M222219</link>
      <description>CODE NOT TESTED.&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select * from A&lt;BR /&gt; where name not in &lt;BR /&gt;( select LN from B );&lt;BR /&gt;quit;</description>
      <pubDate>Wed, 10 Feb 2021 11:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-calling-2-datasets/m-p/718196#M222219</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-02-10T11:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement calling 2 datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-calling-2-datasets/m-p/718227#M222234</link>
      <description>&lt;P&gt;Today, the proper tool for this is a hash object:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set a;
if _n_ = 1
then do;
  declare hash b (dataset:"b (rename=(ln=name))");
  b.definekey("name");
  b.definedone();
end;
if b.check() ne 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Feb 2021 13:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-calling-2-datasets/m-p/718227#M222234</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-10T13:11:20Z</dc:date>
    </item>
  </channel>
</rss>

