<?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: How to use NOT CONTAIN in data step in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-use-NOT-CONTAIN-in-data-step/m-p/362507#M10917</link>
    <description>&lt;P&gt;Should be simple. &amp;nbsp;The meaning of a subsetting if IF statement is that if the condition is NOT met then the data step loop stops. So&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if condition ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is the same as&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if NOT condition then DELETE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So in your case you want&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if name NOT in (&amp;amp;rvar) then delete;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 29 May 2017 14:20:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-05-29T14:20:51Z</dc:date>
    <item>
      <title>How to use NOT CONTAIN in data step</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-use-NOT-CONTAIN-in-data-step/m-p/362505#M10916</link>
      <description>&lt;P&gt;How to drop cases that does not contain any of the given strings of characters delivered through a local macro? &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;                                                
input id $ b c $ d e $ f;                                 
datalines;                                                
AAA 50 11 1 222 22                                        
BBB 35 12 2 250 25                                        
CCC 75 13 3 990 99                                        
;                                                         
run;

proc contents data=test out=vars(keep=name type) noprint; run;

%let rvar = "id", "b";&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let rvar1 = "c", "d", "e", "f";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data vars;
 set vars;
 if name NOT in (&amp;amp;rvar); *Of course this line will not work;                  
 *if name in (&amp;amp;rvar1); 
/*IT works if I set 'rvar' accordingly. 
Though, this can be an option, thre are so many variables
to consider for my data set under this condition; */                
run;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Exisiting data;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9120i2C6B134EDC40A30C/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Existing data" title="Existing data" /&gt;&lt;/P&gt;
&lt;P&gt;Desired data:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9121i708E63E56F82D8A4/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Screen Shot 2017-05-29 at 9.05.41 AM.png" title="Screen Shot 2017-05-29 at 9.05.41 AM.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 14:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-use-NOT-CONTAIN-in-data-step/m-p/362505#M10916</guid>
      <dc:creator>mamun85</dc:creator>
      <dc:date>2017-05-29T14:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to use NOT CONTAIN in data step</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-use-NOT-CONTAIN-in-data-step/m-p/362507#M10917</link>
      <description>&lt;P&gt;Should be simple. &amp;nbsp;The meaning of a subsetting if IF statement is that if the condition is NOT met then the data step loop stops. So&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if condition ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is the same as&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if NOT condition then DELETE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So in your case you want&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if name NOT in (&amp;amp;rvar) then delete;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 May 2017 14:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-use-NOT-CONTAIN-in-data-step/m-p/362507#M10917</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-05-29T14:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use NOT CONTAIN in data step</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-use-NOT-CONTAIN-in-data-step/m-p/362509#M10918</link>
      <description>&lt;P&gt;Ah! The real problem is being a newbie in SAS. I just could have used:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if name in (&amp;amp;rvar) then delete;  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Thanks for your edit and answer Tom.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 14:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-use-NOT-CONTAIN-in-data-step/m-p/362509#M10918</guid>
      <dc:creator>mamun85</dc:creator>
      <dc:date>2017-05-29T14:33:35Z</dc:date>
    </item>
  </channel>
</rss>

