<?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: How to remove decimal for variable that is defined as character in the input statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/670045#M201087</link>
    <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NUM_VALUE = input(ITEM_VALUE, ??  32.);
if NUM_VALUE then ITEM_VALUE=put(NUM_VALUE, comma32.0 -l);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 17 Jul 2020 02:57:31 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-07-17T02:57:31Z</dc:date>
    <item>
      <title>How to remove decimal for variable that is defined as character in the input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/669957#M201059</link>
      <description>&lt;P&gt;I use data step with inflie and input statement to read a csv file. There is a column (Item_Value) that mixes with character and numeric value.&lt;/P&gt;&lt;P&gt;I use informat $50. to define this column. However, when the SAS dataset is generated, I am seeing a decimal after the number (see code and output below).&lt;/P&gt;&lt;P&gt;I have two questions –&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Is there a way to remove the decimal after the number?&lt;/LI&gt;&lt;LI&gt;Is there a way to include comma for thousand?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;

&amp;nbsp; infile "/workfolder/warehouse/data/monthly/June.csv" dlm= ',' missover DSD lrecl=32767 firstobs=2 ;

&amp;nbsp; input

&amp;nbsp;&amp;nbsp;&amp;nbsp; ItemName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : $50.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;

&amp;nbsp;&amp;nbsp;&amp;nbsp; InventoryNumber&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : $50.

&amp;nbsp;&amp;nbsp;&amp;nbsp; Item_Id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : $50.

&amp;nbsp;&amp;nbsp;&amp;nbsp; Item_Value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : $50.

&amp;nbsp;&amp;nbsp;&amp;nbsp; ;

RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ItemName&lt;/TD&gt;&lt;TD&gt;InventoryNumber&lt;/TD&gt;&lt;TD&gt;Item_ID&lt;/TD&gt;&lt;TD&gt;Item_Value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SkinCare&lt;/TD&gt;&lt;TD&gt;AA-372888&lt;/TD&gt;&lt;TD&gt;ItemID1&lt;/TD&gt;&lt;TD&gt;1023.0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SkinCare&lt;/TD&gt;&lt;TD&gt;AA-372888&lt;/TD&gt;&lt;TD&gt;ItemID2&lt;/TD&gt;&lt;TD&gt;0.0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SkinCare&lt;/TD&gt;&lt;TD&gt;AA-372888&lt;/TD&gt;&lt;TD&gt;ItemID3&lt;/TD&gt;&lt;TD&gt;Out of Stock&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SkinCare&lt;/TD&gt;&lt;TD&gt;AA-372888&lt;/TD&gt;&lt;TD&gt;ItemID4&lt;/TD&gt;&lt;TD&gt;N/A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SkinCare&lt;/TD&gt;&lt;TD&gt;AA-372888&lt;/TD&gt;&lt;TD&gt;ItemID5&lt;/TD&gt;&lt;TD&gt;In Stock&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 18:55:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/669957#M201059</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2020-07-16T18:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove decimal for variable that is defined as character in the input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/669975#M201069</link>
      <description>&lt;P&gt;Dealing with column Item_value as given, and assuming the value is either numeric&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or a string (a comment) - I would create two new variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;num_value = input(compress(item_value), ??  best10.);
if missing(num_value) then
 comment_value = compbl(item_value);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 20:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/669975#M201069</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-07-16T20:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove decimal for variable that is defined as character in the input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/670045#M201087</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NUM_VALUE = input(ITEM_VALUE, ??  32.);
if NUM_VALUE then ITEM_VALUE=put(NUM_VALUE, comma32.0 -l);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Jul 2020 02:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/670045#M201087</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-17T02:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove decimal for variable that is defined as character in the input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/670046#M201088</link>
      <description>&lt;P&gt;You could even only keep the numeric variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  value stock
  .S   ='In Stock'
  .O   ='Out of Stock'
  other=[comma32.];
run;

data TEST;
  infile ....;
  input .... ;
  if      ITEM_VALUE = 'In Stock'     then NUM_VALUE = .S;
  else if ITEM_VALUE = 'Out of Stock' then NUM_VALUE = .O;
  else                                     NUM_VALUE = input(ITEM_VALUE, ??  32.);
  format NUM_VALUE stock.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 03:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/670046#M201088</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-17T03:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove decimal for variable that is defined as character in the input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/670816#M201412</link>
      <description>Hi ChrisNZ. Your approach works like a charm. Thanks a lot. I am trying to understand what does the ?? do in the 1st input statement, and what does the comma32.0 -l means in the 2nd put statement. It'd be great if you could share some knowledage with me.</description>
      <pubDate>Mon, 20 Jul 2020 20:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/670816#M201412</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2020-07-20T20:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove decimal for variable that is defined as character in the input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/670842#M201424</link>
      <description>&lt;P&gt;&lt;FONT face="courier new,courier"&gt;??&amp;nbsp;&lt;/FONT&gt;avoids error messages if the value cannot be read with the informat.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;-l&amp;nbsp;&lt;/FONT&gt;left-justifies the formatted value&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 23:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/670842#M201424</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-20T23:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove decimal for variable that is defined as character in the input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/670843#M201425</link>
      <description>Thanks a lot!</description>
      <pubDate>Tue, 21 Jul 2020 00:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-decimal-for-variable-that-is-defined-as-character/m-p/670843#M201425</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2020-07-21T00:03:30Z</dc:date>
    </item>
  </channel>
</rss>

