<?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: Formatting question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formatting-question/m-p/459841#M116837</link>
    <description>Thank you!  What is my z variable is really a variable?  I,e. It could be greater or less than 1?</description>
    <pubDate>Thu, 03 May 2018 20:41:17 GMT</pubDate>
    <dc:creator>mrdlau</dc:creator>
    <dc:date>2018-05-03T20:41:17Z</dc:date>
    <item>
      <title>Formatting question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-question/m-p/459835#M116834</link>
      <description>I have a variable z=10, but in a character format.&lt;BR /&gt;To multiply it by 2,  i convert the z to a numeric during my multiplication:&lt;BR /&gt;2*input(z, 8.2).&lt;BR /&gt;&lt;BR /&gt;However,  my result is .2,  not 20.  Why is this the case?  It is onlu 20 when I use input(z, 8.)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 03 May 2018 20:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-question/m-p/459835#M116834</guid>
      <dc:creator>mrdlau</dc:creator>
      <dc:date>2018-05-03T20:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-question/m-p/459837#M116836</link>
      <description>&lt;P&gt;You are using the wrong informat:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;input(z, 8.2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should be using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;input(z, 8.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use 8.2, it is telling SAS to look for a decimal point.&amp;nbsp; If it doesn't find one, assume the last two digits belong after the decimal point.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 20:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-question/m-p/459837#M116836</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-03T20:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-question/m-p/459841#M116837</link>
      <description>Thank you!  What is my z variable is really a variable?  I,e. It could be greater or less than 1?</description>
      <pubDate>Thu, 03 May 2018 20:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-question/m-p/459841#M116837</guid>
      <dc:creator>mrdlau</dc:creator>
      <dc:date>2018-05-03T20:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-question/m-p/459843#M116838</link>
      <description>&lt;P&gt;Z is already a variable.&amp;nbsp; So I'm not sure what question you are asking.&amp;nbsp; At any rate .....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The meaning of 8.2 doesn't change.&amp;nbsp; It still means to read 8&amp;nbsp; characters, and&amp;nbsp; see if they contain a decimal point.&amp;nbsp; If there is a decimal point, use it.&amp;nbsp; But if there is no decimal point, assume the last two digits should fall after the decimal point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your original variable is numeric, rather than character, you are asking for trouble using the INPUT function.&amp;nbsp; The INPUT function expects to read a character string.&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 20:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-question/m-p/459843#M116838</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-03T20:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-question/m-p/459850#M116840</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/38339"&gt;@mrdlau&lt;/a&gt; wrote:&lt;BR /&gt;I have a variable z=10, but in a character format.&lt;BR /&gt;To multiply it by 2, i convert the z to a numeric during my multiplication:&lt;BR /&gt;2*input(z, 8.2).&lt;BR /&gt;&lt;BR /&gt;However, my result is .2, not 20. Why is this the case? It is onlu 20 when I use input(z, 8.)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You might try a simple&lt;/P&gt;
&lt;P&gt;&amp;nbsp; x = 2*z;&lt;/P&gt;
&lt;P&gt;and examine the result and the log.&lt;/P&gt;
&lt;P&gt;SAS will attempt to convert character&amp;nbsp; values to numeric to do computations like this in a data step. The conversion is usually pretty good. Though if you want to do calculations the question is always why was the variable created as character in the first place.&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 21:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-question/m-p/459850#M116840</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-03T21:00:09Z</dc:date>
    </item>
  </channel>
</rss>

