<?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: Removing multiple comparison operators from a character string and converting to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-multiple-comparison-operators-from-a-character-string/m-p/832448#M329034</link>
    <description>&lt;P&gt;Is so then simply do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id lbstresc $40.;
datalines;
1 &amp;gt;=9.0  
2 &amp;gt;=500  
3 &amp;gt;75    
4 &amp;lt;0.03  
5 &amp;lt;= 500 
;

data want;
   set have;
   w = input(compress(lbstresc, '.', 'kd'), 8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 09 Sep 2022 09:50:35 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2022-09-09T09:50:35Z</dc:date>
    <item>
      <title>Removing multiple comparison operators from a character string and converting to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-multiple-comparison-operators-from-a-character-string/m-p/832446#M329032</link>
      <description>&lt;P&gt;Hello so I'm attempting to modify code from a solution on the community to remove operators from a lab result variable (LBSTRESC) and then convert it to numeric , if possible, within one step. Here is what&amp;nbsp; I have so far&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input id lbstresc $40.;

datalines;
1 &amp;gt;=9.0     
2 &amp;gt;=500     
3 &amp;gt;75
4 &amp;lt;0.03        
5 &amp;lt;= 500             
;
run;

data want;
   set have;
   n_name = lbstresc;
   length word $40 ;
   do word='&amp;gt;', '&amp;gt;=', '&amp;lt;', '&amp;lt;=';
      n_name = tranwrd(' '||n_name,' '||strip(word)||' ', ' ');
  end;
   n_name = compbl(n_name);
   drop word ;
run;&lt;/PRE&gt;
&lt;P&gt;This approach only works for row 5 as there is a space between the operator and the numerical result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smackerz1988_0-1662716564920.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75081i22E99C49A8ADD664/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smackerz1988_0-1662716564920.png" alt="smackerz1988_0-1662716564920.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;However, this is only a row I've inserted to highlight the problem and LBSTRESC for rows 1 to 4 are reflective of the actual data. What do I do to modify the tranwrd statement so the operators are removed in n_name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 09:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-multiple-comparison-operators-from-a-character-string/m-p/832446#M329032</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-09-09T09:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Removing multiple comparison operators from a character string and converting to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-multiple-comparison-operators-from-a-character-string/m-p/832447#M329033</link>
      <description>&lt;P&gt;You just want the numbers 9.0, 500 and so on in a numeric type, correct?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 09:47:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-multiple-comparison-operators-from-a-character-string/m-p/832447#M329033</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-09T09:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Removing multiple comparison operators from a character string and converting to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-multiple-comparison-operators-from-a-character-string/m-p/832448#M329034</link>
      <description>&lt;P&gt;Is so then simply do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id lbstresc $40.;
datalines;
1 &amp;gt;=9.0  
2 &amp;gt;=500  
3 &amp;gt;75    
4 &amp;lt;0.03  
5 &amp;lt;= 500 
;

data want;
   set have;
   w = input(compress(lbstresc, '.', 'kd'), 8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Sep 2022 09:50:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-multiple-comparison-operators-from-a-character-string/m-p/832448#M329034</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-09T09:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Removing multiple comparison operators from a character string and converting to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-multiple-comparison-operators-from-a-character-string/m-p/832449#M329035</link>
      <description>&lt;P&gt;Yes, that's right&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 09:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-multiple-comparison-operators-from-a-character-string/m-p/832449#M329035</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-09-09T09:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Removing multiple comparison operators from a character string and converting to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-multiple-comparison-operators-from-a-character-string/m-p/832450#M329036</link>
      <description>&lt;P&gt;Does my code below work for you?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 09:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-multiple-comparison-operators-from-a-character-string/m-p/832450#M329036</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-09T09:53:21Z</dc:date>
    </item>
  </channel>
</rss>

