<?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 convert character price to numeric in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554767#M7476</link>
    <description>&lt;P&gt;Hello, I am struggling with conversion of a character price to numeric. The data looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-04-29 at 11.24.26 AM.png" style="width: 91px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29100iA8C3EA85A78DDA62/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-04-29 at 11.24.26 AM.png" alt="Screen Shot 2019-04-29 at 11.24.26 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As there is dollar sign there, I did the following. But there is error, and all prices turn out to be 0. Could anyone help me?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	if Price ~=0 then Price_num = input(Price, dollar10.3);
	else Price_num = 0;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 29 Apr 2019 16:25:39 GMT</pubDate>
    <dc:creator>RebeccaJW</dc:creator>
    <dc:date>2019-04-29T16:25:39Z</dc:date>
    <item>
      <title>convert character price to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554767#M7476</link>
      <description>&lt;P&gt;Hello, I am struggling with conversion of a character price to numeric. The data looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-04-29 at 11.24.26 AM.png" style="width: 91px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29100iA8C3EA85A78DDA62/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-04-29 at 11.24.26 AM.png" alt="Screen Shot 2019-04-29 at 11.24.26 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As there is dollar sign there, I did the following. But there is error, and all prices turn out to be 0. Could anyone help me?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	if Price ~=0 then Price_num = input(Price, dollar10.3);
	else Price_num = 0;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Apr 2019 16:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554767#M7476</guid>
      <dc:creator>RebeccaJW</dc:creator>
      <dc:date>2019-04-29T16:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: convert character price to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554769#M7477</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input price $;
cards;
0
$9.99
;

data want;
set have;
price_num=ifn(price ne '0',input(price,comma10.2),0);
format price_num dollar10.2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Apr 2019 16:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554769#M7477</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-29T16:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: convert character price to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554770#M7478</link>
      <description>&lt;P&gt;Don't compare character strings to numbers. SAS will have to convert one or the other to make the comparison.&lt;/P&gt;
&lt;P&gt;Don't add a decimal place value to an INFORMAT.&amp;nbsp; SAS will add an implied decimal point to integer values. So if you read $123,456 using DOLLAR10.3 informat the value will be 123.456 instead of 123456.&lt;/P&gt;
&lt;P&gt;Make sure the width of the informat matches the width of the character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that there is no difference between the DOLLAR informat and the COMMA informat. Both will ignore dollar signs and commas in the string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Price_num = input(Price,comma32.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also you might need to watch out for right aligned values in the character variable.&amp;nbsp; Might not be obvious as in most places SAS will not display the leading spaces.&amp;nbsp; If in doubt print the values using $QUOTE. format and you should be able to see the leading spaces.&amp;nbsp; Ite will be an issue if the width of the informat is too short to reach the end of the actual digits in the character variable.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 16:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554770#M7478</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-29T16:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: convert character price to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554771#M7479</link>
      <description>&lt;P&gt;Try something like &lt;STRONG&gt;Comma&lt;/STRONG&gt;12.2 instead of Dollar19,3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you actually have values with 3 decimals? US currency generally only has 2.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 16:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554771#M7479</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-29T16:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: convert character price to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554776#M7480</link>
      <description>&lt;P&gt;Remember that decimal places on INFORMATs are inappropriate unless you KNOW that the strings were specifically created to support the implied decimal point that means.&amp;nbsp; It won't matter if all of the values are 0, missing, or contain an actual period character.&amp;nbsp; But if some are just digits without any period then resulting value will be divided by 10 to the power of the number of decimal places specified in the informat.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 16:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554776#M7480</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-29T16:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: convert character price to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554777#M7481</link>
      <description>Thank you so much for your help! I appreciate it!</description>
      <pubDate>Mon, 29 Apr 2019 16:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554777#M7481</guid>
      <dc:creator>RebeccaJW</dc:creator>
      <dc:date>2019-04-29T16:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: convert character price to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554778#M7482</link>
      <description>Thank you! I solve that!</description>
      <pubDate>Mon, 29 Apr 2019 16:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554778#M7482</guid>
      <dc:creator>RebeccaJW</dc:creator>
      <dc:date>2019-04-29T16:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: convert character price to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554780#M7483</link>
      <description>Thank you for pointing out it!</description>
      <pubDate>Mon, 29 Apr 2019 16:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554780#M7483</guid>
      <dc:creator>RebeccaJW</dc:creator>
      <dc:date>2019-04-29T16:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: convert character price to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554781#M7484</link>
      <description>Thank you for explanation!</description>
      <pubDate>Mon, 29 Apr 2019 16:51:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/convert-character-price-to-numeric/m-p/554781#M7484</guid>
      <dc:creator>RebeccaJW</dc:creator>
      <dc:date>2019-04-29T16:51:25Z</dc:date>
    </item>
  </channel>
</rss>

