<?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: Where clause in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632911#M187698</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input lab_result $;
	datalines;
abc
123
def
789
a1
;
run;
data want;
 set have;
 if notdigit(strip(lab_result)) then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 18 Mar 2020 11:08:20 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2020-03-18T11:08:20Z</dc:date>
    <item>
      <title>Where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632884#M187687</link>
      <description>I have an lab result containing numerical values and characters&lt;BR /&gt;I want to populate only numeric values&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Mar 2020 09:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632884#M187687</guid>
      <dc:creator>amol2939</dc:creator>
      <dc:date>2020-03-18T09:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632885#M187688</link>
      <description>Any idea how to filter the data</description>
      <pubDate>Wed, 18 Mar 2020 09:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632885#M187688</guid>
      <dc:creator>amol2939</dc:creator>
      <dc:date>2020-03-18T09:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632886#M187689</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292214"&gt;@amol2939&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an approach to achieve this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input lab_result $;
	datalines;
abc
123
def
789
a1
;
run;

data want;
	set have;
	if prxmatch('/^\d+\s*$/',lab_result) then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2020-03-18 à 10.16.19.png" style="width: 74px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36963i7EA5248D21E6D459/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture d’écran 2020-03-18 à 10.16.19.png" alt="Capture d’écran 2020-03-18 à 10.16.19.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;-&amp;gt; nb: the column will be still a character one, even if it display only numbers&lt;/P&gt;
&lt;P&gt;-&amp;gt;the prxmatch function looks for the pattern &lt;CODE class=" language-sas"&gt;/^\d+\s*$&lt;/CODE&gt;: , meaning:&lt;/P&gt;
&lt;P&gt;A string starting (^) with one or more (+) digits (\d) and zero, one or more (*) trailing blanks (\s) at the end ($) of the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 09:26:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632886#M187689</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-18T09:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632891#M187692</link>
      <description>&lt;P&gt;Or something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  if not missing(input(var, ?? best.));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Mar 2020 09:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632891#M187692</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-03-18T09:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632894#M187693</link>
      <description>&lt;P&gt;If your data are more like this, here is another solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines dlm="," truncover;
	input lab_result :$80.;
	datalines;
abc 123 abc 456
123 abc
def 123
;
run;
data want;
	set have;
	array digits(4);
	do i=1 to countw(lab_result);
		digits(i)=scan(lab_result, i, , 'dko');
    end;
    drop i;
run;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2020-03-18 à 10.35.20.png" style="width: 329px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36964i5306E12027CB72AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2020-03-18 à 10.35.20.png" alt="Capture d’écran 2020-03-18 à 10.35.20.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines dlm="," truncover;
	input lab_result :$80.;
	datalines;
abc 123 abc 456
123 abc
def 123
;
run;
data want;
	set have;
	digits = compress(lab_result,,"dK");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2020-03-18 à 10.37.17.png" style="width: 178px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36965i0F29E988D5B54D80/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2020-03-18 à 10.37.17.png" alt="Capture d’écran 2020-03-18 à 10.37.17.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 09:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632894#M187693</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-18T09:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632895#M187694</link>
      <description>&lt;P&gt;Or this:&lt;/P&gt;
&lt;P&gt;If anydigit(VAR);&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 09:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632895#M187694</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-03-18T09:36:53Z</dc:date>
    </item>
    <item>
      <title>This code worked Thanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632901#M187695</link>
      <description>This code worked&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 18 Mar 2020 09:55:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632901#M187695</guid>
      <dc:creator>amol2939</dc:creator>
      <dc:date>2020-03-18T09:55:12Z</dc:date>
    </item>
    <item>
      <title>This works but omit the 1.0, 2.30 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632903#M187696</link>
      <description>This works but omit the 1.0, 2.30 values</description>
      <pubDate>Wed, 18 Mar 2020 09:58:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632903#M187696</guid>
      <dc:creator>amol2939</dc:creator>
      <dc:date>2020-03-18T09:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632911#M187698</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input lab_result $;
	datalines;
abc
123
def
789
a1
;
run;
data want;
 set have;
 if notdigit(strip(lab_result)) then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Mar 2020 11:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632911#M187698</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-03-18T11:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632947#M187708</link>
      <description>Note that when used as an INFORMAT the name BEST is just an alias for the normal numeric informat.  Other aliases are F, D and E.&lt;BR /&gt;You might also consider testing with COMMA and PERCENT informats also.</description>
      <pubDate>Wed, 18 Mar 2020 13:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause/m-p/632947#M187708</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-18T13:00:59Z</dc:date>
    </item>
  </channel>
</rss>

