<?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 can I find the &amp;quot;.&amp;quot;  from those values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285320#M58299</link>
    <description>&lt;P&gt;Hi:&lt;BR /&gt;&amp;nbsp; To work with your IF statements, somebody has to &lt;BR /&gt;1) make up some FAKE data and those who do not know ICD9 or ICD10 will make up the wrong type of FAKE data -- so you could help by posting an example of some data.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;2) after they make up the FAKE data, then they have to make up a program -- you could help by supplying more of the program than just IF statements.&lt;BR /&gt;&lt;BR /&gt;SAS has several functions that might help you here:&lt;BR /&gt;ANYDIGIT and ANYALPHA also NOTDIGIT and NOTALPHA &lt;BR /&gt;Check out the examples in the documentation: &lt;BR /&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/ds2ref/68052/HTML/default/viewer.htm#p1wmqu81yx6jwjn1tdhbltm887z9.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/ds2ref/68052/HTML/default/viewer.htm#p1wmqu81yx6jwjn1tdhbltm887z9.htm&lt;/A&gt;&lt;BR /&gt;using ANYALPHA and ANYDIGIT for testing might be easier than doing what you're doing. &lt;BR /&gt;&lt;BR /&gt;For example if you extract a substr of 4 characters like '2345', it will NOT match single digits such as you show, which is probably why your IF is not working.&lt;BR /&gt;&lt;BR /&gt;cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a program to try that illustrates a better use of ANYALPHA and ANYDIGIT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wrongtest;
  got_e_v = 'n';
  got_number = 'n';
  code='E12345';
  firstchar = substr(code,1,1);
  if firstchar  in ('E', 'V') then got_e_v = 'y';

  next4 = substr(code,2,4);
  if next4 in ('0','1', '2', '3', '4', '5', '6', '7', '8', '9') then got_number = 'y';
run;
 
proc print data=wrongtest;
run;
  
data righttest;
  got_e_v = 'n';
  got_number = 'n';
  code='E12345';
  firstchar = substr(code,1,1);
  if firstchar  in ('E', 'V') then got_e_v = 'y';
 
  next4 = substr(code,2,4);
  ** if anyalpha = 0 means no alpha characters in string;
  ** so if anydigit is tested gt 0 that means entire string is a number;
  if anydigit(next4) gt 0 and anyalpha(next4) =0 then got_number = 'y';
run;

proc print data=righttest;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Jul 2016 18:21:20 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2016-07-18T18:21:20Z</dc:date>
    <item>
      <title>how can I find the "."  from those values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285287#M58286</link>
      <description>&lt;P&gt;For those either contain icd9 or icd10 i want to develop a program that is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if upcase(substr(icd, 1, 1)) in ( 'E' )  and substr(icd, 4, 1)) in ('.") then&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;also I need to find, other than "V", "E", then the value for ICd9 should be numerical, \&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any advice on how to do it?&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 16:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285287#M58286</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-07-18T16:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: how can I find the "."  from those values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285294#M58289</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if upcase(substr(icd, 1, 1)) in ( 'E' ) and substr(icd, 2,4) in ( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9') then i9E="Y"; 

 if upcase(substr(icd, 1, 1)) in ( 'V' ) and substr(icd, 2,4) in ( '0','1', '2', '3', '4', '5', '6', '7', '8', '9') then i9E="Y";
else i9v="N";
if substr(icd, 1,3) in ( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9') then i9n="Y";else i9n="N";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;my code does not work. Can anybody tell what the problem is? Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 17:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285294#M58289</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-07-18T17:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: how can I find the "."  from those values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285318#M58298</link>
      <description>&lt;P&gt;You are comparing 4 long character values from using substr(icd,2,4) with a single character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;notdigit(strip(substr(icd,&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;2&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;4&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;)))= &lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;0&lt;/FONT&gt; &lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; i9e=&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'Y'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 18:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285318#M58298</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-18T18:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: how can I find the "."  from those values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285320#M58299</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt;&amp;nbsp; To work with your IF statements, somebody has to &lt;BR /&gt;1) make up some FAKE data and those who do not know ICD9 or ICD10 will make up the wrong type of FAKE data -- so you could help by posting an example of some data.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;2) after they make up the FAKE data, then they have to make up a program -- you could help by supplying more of the program than just IF statements.&lt;BR /&gt;&lt;BR /&gt;SAS has several functions that might help you here:&lt;BR /&gt;ANYDIGIT and ANYALPHA also NOTDIGIT and NOTALPHA &lt;BR /&gt;Check out the examples in the documentation: &lt;BR /&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/ds2ref/68052/HTML/default/viewer.htm#p1wmqu81yx6jwjn1tdhbltm887z9.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/ds2ref/68052/HTML/default/viewer.htm#p1wmqu81yx6jwjn1tdhbltm887z9.htm&lt;/A&gt;&lt;BR /&gt;using ANYALPHA and ANYDIGIT for testing might be easier than doing what you're doing. &lt;BR /&gt;&lt;BR /&gt;For example if you extract a substr of 4 characters like '2345', it will NOT match single digits such as you show, which is probably why your IF is not working.&lt;BR /&gt;&lt;BR /&gt;cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a program to try that illustrates a better use of ANYALPHA and ANYDIGIT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wrongtest;
  got_e_v = 'n';
  got_number = 'n';
  code='E12345';
  firstchar = substr(code,1,1);
  if firstchar  in ('E', 'V') then got_e_v = 'y';

  next4 = substr(code,2,4);
  if next4 in ('0','1', '2', '3', '4', '5', '6', '7', '8', '9') then got_number = 'y';
run;
 
proc print data=wrongtest;
run;
  
data righttest;
  got_e_v = 'n';
  got_number = 'n';
  code='E12345';
  firstchar = substr(code,1,1);
  if firstchar  in ('E', 'V') then got_e_v = 'y';
 
  next4 = substr(code,2,4);
  ** if anyalpha = 0 means no alpha characters in string;
  ** so if anydigit is tested gt 0 that means entire string is a number;
  if anydigit(next4) gt 0 and anyalpha(next4) =0 then got_number = 'y';
run;

proc print data=righttest;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2016 18:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285320#M58299</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-07-18T18:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: how can I find the "."  from those values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285324#M58301</link>
      <description>&lt;P&gt;What are you trying to do?&lt;/P&gt;
&lt;P&gt;Are you attempting to check if a particular string has the valid format for an ICD code?&lt;/P&gt;
&lt;P&gt;Perhaps regular expressions are the way to go.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 18:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285324#M58301</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-07-18T18:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: how can I find the "."  from those values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285337#M58305</link>
      <description>&lt;P&gt;Here's a short way to check for "E" or "V":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if upcase(icd) in : ('E', 'V')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To check for a number:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if input(icd, ??8.) &amp;gt; 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Combined, they would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if upcase(icd) in : ('E', 'V') or input(icd, ??8.) &amp;gt; . then ....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you also need to check the fourth character for a decimal point?&amp;nbsp; If so, would that apply in every case or just for the E/V or just for the non-E/V values?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 18:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285337#M58305</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-18T18:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: how can I find the "."  from those values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285340#M58307</link>
      <description>&lt;P&gt;if input(icd, ??8.) &amp;gt; 0&lt;/P&gt;
&lt;P&gt;what is ?? stand for? Should i replace it with what?&lt;/P&gt;
&lt;P&gt;yes, I want to check for a decimal point, for the one starts with E, that should be the fourth position that possiblily has ".", for one with "V", that should be the third position that has "."&lt;/P&gt;
&lt;P&gt;and there might be no "." then the values stops there, icd-9 code can be 3-5 characters, No2-5 is numeric&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 19:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285340#M58307</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-07-18T19:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: how can I find the "."  from those values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285344#M58310</link>
      <description>&lt;P&gt;No substitutions needed in ??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When the INPUT function attempts to read something as numeric, it would issue a message when a non-numeric is found.&amp;nbsp; The ?? suppresses dozens and dozens of messages about finding an invalid numeric value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should be getting closer, if not all the way there:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;(&lt;/STRONG&gt;&lt;FONT color="#00CCFF"&gt;(&lt;/FONT&gt;upcase(icd) =: 'V' and &lt;FONT color="#FF0000"&gt;(&lt;/FONT&gt;length(icd) &amp;lt; 4 or substr(icd,4, 1)='.'&lt;FONT color="#993300"&gt;&lt;FONT color="#FF0000"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#00CCFF"&gt;)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&amp;nbsp;&amp;nbsp; &lt;FONT color="#00CCFF"&gt;(&lt;/FONT&gt;upcase(icd) =: 'E' and &lt;FONT color="#FF0000"&gt;(&lt;/FONT&gt;length(icd) &amp;lt; 3 or substr(icd,3, 1)='.'&lt;FONT color="#993300"&gt;&lt;FONT color="#FF0000"&gt;) &lt;STRONG&gt;&lt;FONT color="#000000"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and&amp;nbsp;&amp;nbsp; &lt;FONT color="#339966"&gt;(&lt;/FONT&gt;input(substr(icd,2), ??5.) &amp;gt; .&lt;FONT color="#339966"&gt;)&lt;/FONT&gt; then .....&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 19:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-find-the-quot-quot-from-those-values/m-p/285344#M58310</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-18T19:29:03Z</dc:date>
    </item>
  </channel>
</rss>

