<?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: Char Var (Length 255) will not convert to Numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/782721#M249538</link>
    <description>&lt;P&gt;This code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Event="Yes" then Status=0;
else if X_Dx_Date=. then Status=0;
else Status=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;will&lt;/EM&gt; create a numeric variable&amp;nbsp;&lt;EM&gt;unless&lt;/EM&gt; a character variable with name status is already defined in the step, either by preceding code or in an incoming dataset. To determine this, follow Maxim 2 and Read The Log. If this does not immediately give you a clue, post the&amp;nbsp;&lt;EM&gt;whole&lt;/EM&gt; log of the step by copy/pasting it into a window opened with this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg"&gt;&lt;img src="https://communities.sas.com/skins/images/2FD96521DCF95C42FE57BF2A7CB72678/responsive_peak/images/image_not_found.png" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 28 Nov 2021 08:27:51 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-11-28T08:27:51Z</dc:date>
    <item>
      <title>Char Var (Length 255) will not convert to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/782703#M249532</link>
      <description>&lt;P&gt;I have a dataset in which I created a new variable Status with coding of 0 and 1. For some reason, it automatically coded as character and at a length of 255. I've tried recoding it to numeric, but only get "." as the result. I can see that in the character field, the number is in the right-most position (@255). Is there a way to recode this to numeric and keep the "0" or "1" value at the 255 position? Here is where I created the variable "Status".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;if Event="Yes" then Status=0;&lt;BR /&gt;else if X_Dx_Date=. then Status=0;&lt;BR /&gt;else Status=1;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;*Event was a character value and X_Dx_Date was a date value.&lt;/EM&gt;&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="dmwilliams_0-1638053683913.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66154i4AAC5F9B8A59B481/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dmwilliams_0-1638053683913.png" alt="dmwilliams_0-1638053683913.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Tried recoding but only get that 255 is too long with this (also tried 3. instead of 255 and got "." for all values):&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;numeric_var = input(Status, 255.);&amp;nbsp;&lt;BR /&gt;drop Status;&lt;BR /&gt;rename numeric_var = Status;&amp;nbsp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you! I know this must be simple, but everything I've tried has failed.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Nov 2021 22:59:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/782703#M249532</guid>
      <dc:creator>dmwilliams</dc:creator>
      <dc:date>2021-11-27T22:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Char Var (Length 255) will not convert to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/782705#M249533</link>
      <description>&lt;P&gt;Use compress function to get rid of the blanks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
a='                                                                         1';
b=input(compress(a),1.); put b=;
output;
a='                                                                         0';
b=input(compress(a),1.); put b=;
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 27 Nov 2021 23:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/782705#M249533</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-27T23:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Char Var (Length 255) will not convert to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/782708#M249534</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; For some reason&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Fix that.&lt;/P&gt;
&lt;P&gt;1. What does the log say?&lt;/P&gt;
&lt;P&gt;2. It seems you already have a variable STATUS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Nov 2021 01:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/782708#M249534</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-28T01:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Char Var (Length 255) will not convert to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/782721#M249538</link>
      <description>&lt;P&gt;This code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Event="Yes" then Status=0;
else if X_Dx_Date=. then Status=0;
else Status=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;will&lt;/EM&gt; create a numeric variable&amp;nbsp;&lt;EM&gt;unless&lt;/EM&gt; a character variable with name status is already defined in the step, either by preceding code or in an incoming dataset. To determine this, follow Maxim 2 and Read The Log. If this does not immediately give you a clue, post the&amp;nbsp;&lt;EM&gt;whole&lt;/EM&gt; log of the step by copy/pasting it into a window opened with this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg"&gt;&lt;img src="https://communities.sas.com/skins/images/2FD96521DCF95C42FE57BF2A7CB72678/responsive_peak/images/image_not_found.png" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Nov 2021 08:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/782721#M249538</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-28T08:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Char Var (Length 255) will not convert to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/784138#M250175</link>
      <description>&lt;P&gt;Yes, nothing is immediately apparent. The log has no errors, but has this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;BR /&gt;1874:53 1875:13&lt;/P&gt;</description>
      <pubDate>Sun, 05 Dec 2021 06:16:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/784138#M250175</guid>
      <dc:creator>dmwilliams</dc:creator>
      <dc:date>2021-12-05T06:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: Char Var (Length 255) will not convert to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/784139#M250176</link>
      <description>&lt;P&gt;Yep, there was another variable STATUS. THANK YOU!&lt;/P&gt;</description>
      <pubDate>Sun, 05 Dec 2021 06:26:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/784139#M250176</guid>
      <dc:creator>dmwilliams</dc:creator>
      <dc:date>2021-12-05T06:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Char Var (Length 255) will not convert to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/784140#M250177</link>
      <description>&lt;P&gt;What, in this case, would a and b represent?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Dec 2021 06:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/784140#M250177</guid>
      <dc:creator>dmwilliams</dc:creator>
      <dc:date>2021-12-05T06:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Char Var (Length 255) will not convert to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/784141#M250178</link>
      <description>How do you expect to create a numerical variable when you already have a character variable of the same name?  You can't.</description>
      <pubDate>Sun, 05 Dec 2021 06:31:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-Var-Length-255-will-not-convert-to-Numeric/m-p/784141#M250178</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-12-05T06:31:19Z</dc:date>
    </item>
  </channel>
</rss>

