<?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 &amp;quot;Not in&amp;quot; not working in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/quot-Not-in-quot-not-working/m-p/579618#M13471</link>
    <description>&lt;P&gt;I have two variables patid ( patient ID) and dx1 (code).&amp;nbsp;&lt;/P&gt;&lt;P&gt;For all patient id (patid) I want only those dx1 where dx1 start with with '380' or '470' OR dx1 is equal to '98006'&amp;nbsp;&lt;/P&gt;&lt;P&gt;and replace any other dx1 with missing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find below the SAS code -&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class="language-sas"&gt;data abc;
infile datalines ;
input patid dx1 $ ;
datalines;
123 38000
122 47001
123 38010
124 78011
125 47021
126 47031
127 38005
128 98006
;
run;

data abc1;
set abc;
if  upcase(substr(dx1,1,3)) not in ('380','470')  
or
 upcase(dx1) not in ('98006')  then dx1 = '';    
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The result is -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dx1 missing for all patid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why is that happening?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Aug 2019 10:25:14 GMT</pubDate>
    <dc:creator>SAS1918</dc:creator>
    <dc:date>2019-08-07T10:25:14Z</dc:date>
    <item>
      <title>"Not in" not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/quot-Not-in-quot-not-working/m-p/579618#M13471</link>
      <description>&lt;P&gt;I have two variables patid ( patient ID) and dx1 (code).&amp;nbsp;&lt;/P&gt;&lt;P&gt;For all patient id (patid) I want only those dx1 where dx1 start with with '380' or '470' OR dx1 is equal to '98006'&amp;nbsp;&lt;/P&gt;&lt;P&gt;and replace any other dx1 with missing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find below the SAS code -&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class="language-sas"&gt;data abc;
infile datalines ;
input patid dx1 $ ;
datalines;
123 38000
122 47001
123 38010
124 78011
125 47021
126 47031
127 38005
128 98006
;
run;

data abc1;
set abc;
if  upcase(substr(dx1,1,3)) not in ('380','470')  
or
 upcase(dx1) not in ('98006')  then dx1 = '';    
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The result is -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dx1 missing for all patid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why is that happening?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 10:25:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/quot-Not-in-quot-not-working/m-p/579618#M13471</guid>
      <dc:creator>SAS1918</dc:creator>
      <dc:date>2019-08-07T10:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: "Not in" not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/quot-Not-in-quot-not-working/m-p/579622#M13472</link>
      <description>&lt;P&gt;The combined condition is true for all observations.&lt;/P&gt;
&lt;P&gt;In all cases but the last, dx1 is not equal to '98006', so the second part of the condition is true, and in the last case, the first three digits are not in your list, so the first part of the condition is true. Did you intend to use "and" instead of "or"?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 10:35:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/quot-Not-in-quot-not-working/m-p/579622#M13472</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-07T10:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: "Not in" not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/quot-Not-in-quot-not-working/m-p/579628#M13473</link>
      <description>&lt;P&gt;Please try the below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
infile datalines ;
input patid dx1 $ ;
if not (prxmatch('m/^380/i',dx1) or prxmatch('m/^470/i',dx1) or prxmatch('m/^98006/i',dx1)) then dx1='';
datalines;
123 38000
122 47001
123 38010
124 78011
125 47021
126 47031
127 38005
128 98006
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Aug 2019 10:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/quot-Not-in-quot-not-working/m-p/579628#M13473</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-08-07T10:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: "Not in" not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/quot-Not-in-quot-not-working/m-p/579636#M13474</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/264470"&gt;@SAS1918&lt;/a&gt;&amp;nbsp; &amp;nbsp;Are you sure that you are after "NOT IN"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have stated&amp;nbsp; &lt;STRONG&gt;&lt;EM&gt;"&amp;nbsp;I &lt;U&gt;want&lt;/U&gt; only those dx1 where dx1 start with with '380' or '470' OR dx1 is equal to '98006' "&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyways&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data abc;
infile datalines ;
input patid dx1 $ ;
datalines;
123 38000
122 47001
123 38010
124 78011
125 47021
126 47031
127 38005
128 98006
;
run;
/*if you want*/
data want;
set abc;
/*if you want*/
where dx1 in :('380','470') or dx1='98006' ;
run;

/*if you DO NOT want*/
data want;
set abc;
/*if you DO NOT want*/
where dx1 not in :('380','470') and dx1^='98006' ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 11:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/quot-Not-in-quot-not-working/m-p/579636#M13474</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-07T11:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: "Not in" not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/quot-Not-in-quot-not-working/m-p/579639#M13476</link>
      <description>&lt;P&gt;You are almost there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
infile datalines ;
input patid dx1 $ ;
datalines;
123 38000
122 47001
123 38010
124 78011
125 47021
126 47031
127 38005
128 98006
;
run;

data abc1;
set abc;
if  dx1 not in: ('380','470','98006')  then dx1 = ' ';    
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Aug 2019 12:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/quot-Not-in-quot-not-working/m-p/579639#M13476</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-08-07T12:07:37Z</dc:date>
    </item>
  </channel>
</rss>

