<?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: Why do numerical values with a character format work as numbers when applying mathematical funct in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-do-numerical-values-with-a-character-format-work-as-numbers/m-p/485734#M126246</link>
    <description>&lt;P&gt;SAS tries to interpret the characters as numeric if forced to do so.&lt;/P&gt;&lt;P&gt;Check your log for this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will get another log message if the numeric conversion is unsuccessful.&lt;/P&gt;&lt;P&gt;If you run this code, SAS will try to convert the character "U" to numeric and fail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data sample;
x='U';
y=10*x;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;NOTE: Invalid numeric data, x='U' , at line 26 column 6.&lt;BR /&gt;x=U y=. _ERROR_=1 _N_=1&lt;BR /&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 at 26:5&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A healthy approach to SAS programming is to avoid these forced conversions.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Aug 2018 12:17:06 GMT</pubDate>
    <dc:creator>CalleJ</dc:creator>
    <dc:date>2018-08-10T12:17:06Z</dc:date>
    <item>
      <title>Why do numerical values with a character format work as numbers when applying mathematical functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-numerical-values-with-a-character-format-work-as-numbers/m-p/485731#M126243</link>
      <description>&lt;P&gt;If i have a code like this&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data sample;
x='100';
y=10*x;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the result would be y= 1000&lt;/P&gt;&lt;P&gt;But x is a character and not a number so applying a mathematical function to it should not work.&lt;/P&gt;&lt;P&gt;why does this work?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 12:00:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-numerical-values-with-a-character-format-work-as-numbers/m-p/485731#M126243</guid>
      <dc:creator>riyaaora275</dc:creator>
      <dc:date>2018-08-10T12:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why do numerical values with a character format work as numbers when applying mathematical funct</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-numerical-values-with-a-character-format-work-as-numbers/m-p/485733#M126245</link>
      <description>&lt;P&gt;SAS was designed to do that. See:&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a001276672.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a001276672.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 12:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-numerical-values-with-a-character-format-work-as-numbers/m-p/485733#M126245</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-08-10T12:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why do numerical values with a character format work as numbers when applying mathematical funct</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-numerical-values-with-a-character-format-work-as-numbers/m-p/485734#M126246</link>
      <description>&lt;P&gt;SAS tries to interpret the characters as numeric if forced to do so.&lt;/P&gt;&lt;P&gt;Check your log for this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will get another log message if the numeric conversion is unsuccessful.&lt;/P&gt;&lt;P&gt;If you run this code, SAS will try to convert the character "U" to numeric and fail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data sample;
x='U';
y=10*x;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;NOTE: Invalid numeric data, x='U' , at line 26 column 6.&lt;BR /&gt;x=U y=. _ERROR_=1 _N_=1&lt;BR /&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 at 26:5&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A healthy approach to SAS programming is to avoid these forced conversions.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 12:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-numerical-values-with-a-character-format-work-as-numbers/m-p/485734#M126246</guid>
      <dc:creator>CalleJ</dc:creator>
      <dc:date>2018-08-10T12:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why do numerical values with a character format work as numbers when applying mathematical funct</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-numerical-values-with-a-character-format-work-as-numbers/m-p/485737#M126248</link>
      <description>&lt;P&gt;This uses implicit conversion, i.e. if it can, SAS will automatically try to convert the text to number.&amp;nbsp; It is however IMO not recommended.&amp;nbsp; Never let the computer decide for you what you want to do.&amp;nbsp; Use explicit conversion&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;always&lt;/STRONG&gt;&lt;/U&gt;.&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; sample&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  x&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'100'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  y&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;10&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*input(&lt;/SPAN&gt;x,8.)&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Aug 2018 12:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-numerical-values-with-a-character-format-work-as-numbers/m-p/485737#M126248</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-10T12:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why do numerical values with a character format work as numbers when applying mathematical funct</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-numerical-values-with-a-character-format-work-as-numbers/m-p/485738#M126249</link>
      <description>&lt;PRE&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      28:6   &lt;/PRE&gt;
&lt;P&gt;Did you notice this in log, SAS will automatically try to convert it into numeric.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If SAS can't convert the value then y will be missing. Check the log.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data sample;
x='1,000';
y=10*x;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      28:6   
NOTE: Compression was disabled for data set WORK.SAMPLE because compression overhead would increase the size of the data set.
NOTE: Invalid numeric data, x='1,000' , at line 28 column 6.
x=1,000 y=. _ERROR_=1 _N_=1
NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 at 28:5 &lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Aug 2018 12:20:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-numerical-values-with-a-character-format-work-as-numbers/m-p/485738#M126249</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-08-10T12:20:45Z</dc:date>
    </item>
  </channel>
</rss>

