<?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 ignore non numeric portion of a character variable and convert it to numeric? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-ignore-non-numeric-portion-of-a-character-variable-and/m-p/103409#M21584</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, you can use a compress function here in ways it fits best and if the variable is non numeric use the input function to convert it to numeric.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example: kk = compress(lab,"&amp;lt;= ");&amp;nbsp; /*Here it will compress &amp;lt;= and blanks in the variable*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kk = compress(lab,"1234567890","k")&amp;nbsp;&amp;nbsp; /* This will keep only 1234567890 values in the variable and it you have a decimal you can include . in the list*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use of input function: jj = input(kk,best12.);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /***Assigning informat to the variable******/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format jj best12.;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*****Output/Display format***************/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Somi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Oct 2013 22:34:36 GMT</pubDate>
    <dc:creator>hsharmas</dc:creator>
    <dc:date>2013-10-03T22:34:36Z</dc:date>
    <item>
      <title>How to ignore non numeric portion of a character variable and convert it to numeric?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-ignore-non-numeric-portion-of-a-character-variable-and/m-p/103408#M21583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a variable which has values like &amp;gt;=500, &amp;gt;75 in addition to truly numeric values in integers.&lt;/P&gt;&lt;P&gt;I need to convert it to a numeric variable while ignoring the =, &amp;lt;= etc.&lt;/P&gt;&lt;P&gt;The SAS input function does not work in this case.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Here is a sample set&lt;/P&gt;&lt;P&gt;data what;&lt;/P&gt;&lt;P&gt;input&amp;nbsp; $lab;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;&amp;lt;=500&lt;/P&gt;&lt;P&gt;&amp;lt;75&lt;/P&gt;&lt;P&gt;=&amp;lt;100&lt;/P&gt;&lt;P&gt;2000&lt;/P&gt;&lt;P&gt;300&lt;/P&gt;&lt;P&gt;400&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 22:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-ignore-non-numeric-portion-of-a-character-variable-and/m-p/103408#M21583</guid>
      <dc:creator>saurabhc</dc:creator>
      <dc:date>2013-10-03T22:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to ignore non numeric portion of a character variable and convert it to numeric?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-ignore-non-numeric-portion-of-a-character-variable-and/m-p/103409#M21584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, you can use a compress function here in ways it fits best and if the variable is non numeric use the input function to convert it to numeric.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example: kk = compress(lab,"&amp;lt;= ");&amp;nbsp; /*Here it will compress &amp;lt;= and blanks in the variable*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kk = compress(lab,"1234567890","k")&amp;nbsp;&amp;nbsp; /* This will keep only 1234567890 values in the variable and it you have a decimal you can include . in the list*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use of input function: jj = input(kk,best12.);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /***Assigning informat to the variable******/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format jj best12.;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*****Output/Display format***************/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Somi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 22:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-ignore-non-numeric-portion-of-a-character-variable-and/m-p/103409#M21584</guid>
      <dc:creator>hsharmas</dc:creator>
      <dc:date>2013-10-03T22:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to ignore non numeric portion of a character variable and convert it to numeric?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-ignore-non-numeric-portion-of-a-character-variable-and/m-p/103410#M21585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried substr function. It is a longer way of doing this job.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;if &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;substr(result, &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;) in(&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: 'Courier New'; font-size: 10pt;"&gt;"&amp;lt;="&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: 'Courier New'; font-size: 10pt;"&gt;"=&amp;lt;"&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: 'Courier New'; font-size: 10pt;"&gt;"&amp;gt;="&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;)&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; results=substr(result,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; substr(result,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;)=&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: 'Courier New'; font-size: 10pt;"&gt;"&amp;lt;"&lt;/SPAN&gt; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; results=substr(result, &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;results=result;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;results1=input(results,&lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;best12.&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Your code totally works though.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 22:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-ignore-non-numeric-portion-of-a-character-variable-and/m-p/103410#M21585</guid>
      <dc:creator>saurabhc</dc:creator>
      <dc:date>2013-10-03T22:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to ignore non numeric portion of a character variable and convert it to numeric?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-ignore-non-numeric-portion-of-a-character-variable-and/m-p/103411#M21586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;K is a modifier and is used for keep. Also, in your method you could do it when obs are less as you can look and check where is the position of &amp;lt;&amp;gt;=, and impossible when their are thousands of obs. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this link:&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212246.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212246.htm"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rate me please if I answered you query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Somi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 22:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-ignore-non-numeric-portion-of-a-character-variable-and/m-p/103411#M21586</guid>
      <dc:creator>hsharmas</dc:creator>
      <dc:date>2013-10-03T22:56:00Z</dc:date>
    </item>
  </channel>
</rss>

