<?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 Override Character values have been converted to numeric values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Override-Character-values-have-been-converted-to-numeric/m-p/768334#M243703</link>
    <description>&lt;P&gt;Hi there, I have to overwrite some character data to change to a value beginning in 0. When I go to perform the data step, SAS automatically converts the data to numeric and it is not stored properly. Here is an example of the data and code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Existing Value for character variable ID with length 3: AAA&lt;/P&gt;&lt;P&gt;Desired Value for value AAA in same character variable ID with length 3: 0AA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;Data work.data;&lt;/P&gt;&lt;P&gt;set work.dataold&lt;/P&gt;&lt;P&gt;length ID $3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;if ID="AAA" then ID= "0AA";&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this program SAS converts the value "0AA" to numeric, but I want it to stay as a character.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Sep 2021 17:01:49 GMT</pubDate>
    <dc:creator>DRM51</dc:creator>
    <dc:date>2021-09-17T17:01:49Z</dc:date>
    <item>
      <title>How to Override Character values have been converted to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Override-Character-values-have-been-converted-to-numeric/m-p/768334#M243703</link>
      <description>&lt;P&gt;Hi there, I have to overwrite some character data to change to a value beginning in 0. When I go to perform the data step, SAS automatically converts the data to numeric and it is not stored properly. Here is an example of the data and code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Existing Value for character variable ID with length 3: AAA&lt;/P&gt;&lt;P&gt;Desired Value for value AAA in same character variable ID with length 3: 0AA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;Data work.data;&lt;/P&gt;&lt;P&gt;set work.dataold&lt;/P&gt;&lt;P&gt;length ID $3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;if ID="AAA" then ID= "0AA";&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this program SAS converts the value "0AA" to numeric, but I want it to stay as a character.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 17:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Override-Character-values-have-been-converted-to-numeric/m-p/768334#M243703</guid>
      <dc:creator>DRM51</dc:creator>
      <dc:date>2021-09-17T17:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to Override Character values have been converted to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Override-Character-values-have-been-converted-to-numeric/m-p/768336#M243705</link>
      <description>&lt;P&gt;Please show your log.&lt;/P&gt;
&lt;P&gt;The only reason SAS will show messages about converting to/from numeric with your posted code would be if ID already exists on DATAOLD as a numeric variable. In which case ID could never have a value like 'AA'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 17:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Override-Character-values-have-been-converted-to-numeric/m-p/768336#M243705</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-17T17:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to Override Character values have been converted to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Override-Character-values-have-been-converted-to-numeric/m-p/768363#M243721</link>
      <description>&lt;P&gt;Here is the results with proc contents:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Variable&lt;/TD&gt;&lt;TD&gt;Type&lt;/TD&gt;&lt;TD&gt;Len&lt;/TD&gt;&lt;TD&gt;Format&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;$3.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA work.data;&lt;BR /&gt;813 set work.dataold;&lt;BR /&gt;814 length UPL_ID $3;&lt;BR /&gt;821 IF UPL_ID='AAA' and month &amp;gt;4 and year=2020 then UPL_ID="0A1" ';&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;821:64 842:63 849:63&lt;BR /&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;821:70 842:69 849:69&lt;BR /&gt;NOTE: Invalid numeric data, '0A1' , at line 821 column 64.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 19:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Override-Character-values-have-been-converted-to-numeric/m-p/768363#M243721</guid>
      <dc:creator>DRM51</dc:creator>
      <dc:date>2021-09-17T19:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to Override Character values have been converted to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Override-Character-values-have-been-converted-to-numeric/m-p/768374#M243723</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/357927"&gt;@DRM51&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here is the results with proc contents:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Variable&lt;/TD&gt;
&lt;TD&gt;Type&lt;/TD&gt;
&lt;TD&gt;Len&lt;/TD&gt;
&lt;TD&gt;Format&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;ID&lt;/TD&gt;
&lt;TD&gt;Char&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;$3.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA work.data;&lt;BR /&gt;813 set work.dataold;&lt;BR /&gt;814 length UPL_ID $3;&lt;BR /&gt;821 IF UPL_ID='AAA' and month &amp;gt;4 and year=2020 then UPL_ID="0A1" ';&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;821:64 842:63 849:63&lt;BR /&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;821:70 842:69 849:69&lt;BR /&gt;NOTE: Invalid numeric data, '0A1' , at line 821 column 64.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And where is the detail about the variable UPL_ID???&lt;/P&gt;
&lt;P&gt;You show a variable named ID. That is not the same as UPL_ID. You do not show any code using a variable named ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Copy an entire data step or procedure along with all the messages. Copy all of it from the log. Then on the forum open a text box using the &amp;lt;/&amp;gt; at the top of message window and paste. This preserves the content and the diagnostic information SAS provides.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "code" you pasted like would not run at all because after what ever edit you did there is an extra ' at the end of&lt;/P&gt;
&lt;PRE&gt; then UPL_ID="0A1" ';&lt;/PRE&gt;
&lt;P&gt;Which means that statement did not have an ending semicolon and would be trying to use the next line to end that statement which would very likely cause all sorts of headaches.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 20:49:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Override-Character-values-have-been-converted-to-numeric/m-p/768374#M243723</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-17T20:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to Override Character values have been converted to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Override-Character-values-have-been-converted-to-numeric/m-p/768410#M243736</link>
      <description>&lt;P&gt;The NOTEs do not correspond to the log as posted. Line 821 has only 60 columns.&lt;/P&gt;
&lt;P&gt;Please post the&amp;nbsp;&lt;EM&gt;complete&lt;/EM&gt; log of the step by copy/pasting it (NO editing!) 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" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Sep 2021 06:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Override-Character-values-have-been-converted-to-numeric/m-p/768410#M243736</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-18T06:20:18Z</dc:date>
    </item>
  </channel>
</rss>

