<?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 How to extract clean numerical data from a messy char variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-clean-numerical-data-from-a-messy-char-variable/m-p/511978#M137829</link>
    <description>&lt;P&gt;I have a $20 char variable that can take the following values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input var $20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;0.02&lt;/P&gt;&lt;P&gt;0.0125&lt;/P&gt;&lt;P&gt;0.05%&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;0.0100&lt;/P&gt;&lt;P&gt;0.5ABC&lt;/P&gt;&lt;P&gt;0.02or&amp;gt;5&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to keep only observations with purely numerical values: 0.02, 0.0125, 0.05%, 3, 0.0100. I also want these values to be formatted. How can I do this?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Nov 2018 23:04:41 GMT</pubDate>
    <dc:creator>xyxu</dc:creator>
    <dc:date>2018-11-10T23:04:41Z</dc:date>
    <item>
      <title>How to extract clean numerical data from a messy char variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-clean-numerical-data-from-a-messy-char-variable/m-p/511978#M137829</link>
      <description>&lt;P&gt;I have a $20 char variable that can take the following values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input var $20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;0.02&lt;/P&gt;&lt;P&gt;0.0125&lt;/P&gt;&lt;P&gt;0.05%&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;0.0100&lt;/P&gt;&lt;P&gt;0.5ABC&lt;/P&gt;&lt;P&gt;0.02or&amp;gt;5&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to keep only observations with purely numerical values: 0.02, 0.0125, 0.05%, 3, 0.0100. I also want these values to be formatted. How can I do this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 23:04:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-clean-numerical-data-from-a-messy-char-variable/m-p/511978#M137829</guid>
      <dc:creator>xyxu</dc:creator>
      <dc:date>2018-11-10T23:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract clean numerical data from a messy char variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-clean-numerical-data-from-a-messy-char-variable/m-p/511980#M137831</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/99650"&gt;@xyxu&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;From looking at your sample data, it appears that it can be as simple as using the COMMAw. informat:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                         
  input var $20. ;                  
  cards ;                           
0.02                                
0.0125                              
0.05%                               
3                                   
0.0100                              
0.5ABC                              
0.02or&amp;gt;5                            
run ;                               
                                    
data want ;                         
  set have ;                        
  value = input (var, ?? comma20.) ;
  if N (value) ;                    
run ;                               
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, be aware that COMMAw. merely strips the % sign (and also $ and some other characters) - it doesn't divide the result by 100. If that is what you want, you'd have to add more logic to handle it. Also, you aren't telling &lt;EM&gt;how&lt;/EM&gt; you want to format the resulting variable, so I can't offer an advice on that head.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Nov 2018 00:04:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-clean-numerical-data-from-a-messy-char-variable/m-p/511980#M137831</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-11-11T00:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract clean numerical data from a messy char variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-clean-numerical-data-from-a-messy-char-variable/m-p/511985#M137836</link>
      <description>&lt;P&gt;Use informat &lt;STRONG&gt;percent20.&lt;/STRONG&gt; instead. It also removes dollar signs, negates values in parentheses and&amp;nbsp;divides by 100 only if a percent sign is present.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Nov 2018 03:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-clean-numerical-data-from-a-messy-char-variable/m-p/511985#M137836</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-11-11T03:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract clean numerical data from a messy char variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-clean-numerical-data-from-a-messy-char-variable/m-p/511987#M137838</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An excellent suggestion if this is indeed what the OP wants.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Nov 2018 04:06:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-clean-numerical-data-from-a-messy-char-variable/m-p/511987#M137838</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-11-11T04:06:53Z</dc:date>
    </item>
  </channel>
</rss>

