<?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: character to numeric by adding 0? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347099#M80128</link>
    <description>hmmmm....i have to look into how to do this. Thanks!</description>
    <pubDate>Tue, 04 Apr 2017 16:07:30 GMT</pubDate>
    <dc:creator>K_S</dc:creator>
    <dc:date>2017-04-04T16:07:30Z</dc:date>
    <item>
      <title>character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347070#M80115</link>
      <description>&lt;P&gt;The database that I am working with records lab values as character variables beacuse lab techs sometimes write notes/comments instead of enter a numeric lab results.&lt;/P&gt;&lt;P&gt;I have been converting this variable to numeric by adding a 0 to it (i.e. character_var+0) ...this seems to do the trick, but am wondering if there are any downsides to doing this. I am only interested in the numeric measurements so other than ending up with missing fields where there were notes/comments are there any downsides to doing this?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 15:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347070#M80115</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-04-04T15:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347075#M80118</link>
      <description>&lt;P&gt;This is known as implicit type conversion, basically having SAS automatically convert a character to a numeric and you'll likely have a note in the log that this is happening. It is normally considered bad programming practice and should be avoided. The normal character to numeric conversion in SAS is done through the INPUT function. If you know the format of the numeric lab values, you can use INPUT(lab value,informat.). If it is somewhat variable (sometimes 4 characters, sometimes 13, etc.) you can use the BEST. informat. References for the INPUT function and the BEST informat are available in SAS documentation if you want more background.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 15:21:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347075#M80118</guid>
      <dc:creator>JoshB</dc:creator>
      <dc:date>2017-04-04T15:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347080#M80121</link>
      <description>unfortunately that is not an option, I have no ways of inputting the values&lt;BR /&gt;(or are just unaware of how it could be done).&lt;BR /&gt;Thank you for your feedback!&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Tue, 04 Apr 2017 15:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347080#M80121</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-04-04T15:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347081#M80122</link>
      <description>&lt;P&gt;Some organizations with strict code management policies will require "clean" log results meaning no errors, warnings and sometimes even no notes. This process may cause a violation of that policy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally if that were my data I would probably address this sort of issue at the data read step and either create to variables, If the notes were needed later or read as numeric to begin with and suppress the resulting "invalid data" messages that are going to insue.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 15:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347081#M80122</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-04T15:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347084#M80123</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127053"&gt;@K_S&lt;/a&gt; wrote:&lt;BR /&gt;unfortunately that is not an option, I have no ways of inputting the values&lt;BR /&gt;(or are just unaware of how it could be done).&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The recommendation was not that you input the values. The recommendation was that you use the SAS function INPUT instead of adding zero to the value.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 15:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347084#M80123</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-04-04T15:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347087#M80125</link>
      <description>&lt;P&gt;I can only agree with the other posters. &amp;nbsp;This uses implicit (i.e. your not specifying it, your letting the system guess it) conversion. &amp;nbsp;Always a bad technique. &amp;nbsp;Always make sure you - the person closest to it - is in complete control. &amp;nbsp;Use the input() function.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 15:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347087#M80125</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-04T15:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347095#M80126</link>
      <description>&lt;P&gt;While I generally agree, here are some tools to help cope with the situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;numval = input(charval, ??20.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will convert the existing values to their numeric equivalent, if possible.&amp;nbsp; However, adding ?? will suppress messages about invalid data if the original set of characters are not numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For cleaning the data, or perhaps being more rigorous about what can be converted and what can't, you could try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=labdata;&lt;/P&gt;
&lt;P&gt;tables charval;&lt;/P&gt;
&lt;P&gt;where charval &amp;gt; ' ' and input(charval, ??20.) = .;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will give you a table of all the values that can't be converted, so you can inspect them and see if there is something you might be able to do with them.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 16:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347095#M80126</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-04T16:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347099#M80128</link>
      <description>hmmmm....i have to look into how to do this. Thanks!</description>
      <pubDate>Tue, 04 Apr 2017 16:07:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/347099#M80128</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-04-04T16:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626926#M184969</link>
      <description>Hello&lt;BR /&gt;My data lines is as follow&lt;BR /&gt;Data abc;&lt;BR /&gt;Input a $ b;&lt;BR /&gt;Data lines;&lt;BR /&gt;Normal 0(0.0)&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;Can anyone let me know how to convert it into numeric format</description>
      <pubDate>Mon, 24 Feb 2020 17:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626926#M184969</guid>
      <dc:creator>amol2939</dc:creator>
      <dc:date>2020-02-24T17:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626927#M184970</link>
      <description>&lt;P&gt;What would be the resulting numeric from this conversion?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 17:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626927#M184970</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-24T17:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626928#M184971</link>
      <description />
      <pubDate>Mon, 24 Feb 2020 17:37:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626928#M184971</guid>
      <dc:creator>amol2939</dc:creator>
      <dc:date>2020-02-24T17:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626929#M184972</link>
      <description>normal 0(0.0)</description>
      <pubDate>Mon, 24 Feb 2020 17:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626929#M184972</guid>
      <dc:creator>amol2939</dc:creator>
      <dc:date>2020-02-24T17:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626931#M184974</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292214"&gt;@amol2939&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;normal 0(0.0)&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is not numeric. Can you explain further?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 17:40:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626931#M184974</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-24T17:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626965#M184982</link>
      <description />
      <pubDate>Mon, 24 Feb 2020 18:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626965#M184982</guid>
      <dc:creator>amol2939</dc:creator>
      <dc:date>2020-02-24T18:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric by adding 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626999#M184999</link>
      <description>&lt;P&gt;Please open new threads for new questions in future.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;0 is a number&lt;/P&gt;
&lt;P&gt;( is not a number&lt;/P&gt;
&lt;P&gt;0.0 is a number&lt;/P&gt;
&lt;P&gt;) is not a number&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get the two separate numbers then you need two variables, and string parse the string you have:&lt;/P&gt;
&lt;PRE&gt;data abc;
  input a $ b $;
  c=input(scan(b,"(",1),best.);
  d=input(compress(scan(b,"(",2),")"),best.);
data lines;
Normal 0(0.0)
run;&lt;/PRE&gt;
&lt;P&gt;c takes the first number (i.e. the text before the opening bracket) and converts it to numeric using best format.&lt;/P&gt;
&lt;P&gt;d takes the second number (i.e. the text after the opening bracket), removes the closing bracket, then converts to number using best format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume this is from clinical outputs where 0 is the count, and 0.0 is the percentage of population, you should be refering to the underlying data, &lt;STRONG&gt;not&lt;/STRONG&gt; the produced output!&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 19:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric-by-adding-0/m-p/626999#M184999</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2020-02-24T19:59:43Z</dc:date>
    </item>
  </channel>
</rss>

