<?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 specify informat  for numeric values with $ sign in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490345#M128269</link>
    <description>&lt;P&gt;Wonderful worked like a charm without any modifications.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your help.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Aug 2018 07:03:02 GMT</pubDate>
    <dc:creator>ariyurjana</dc:creator>
    <dc:date>2018-08-28T07:03:02Z</dc:date>
    <item>
      <title>how to specify informat  for numeric values with $ sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490322#M128251</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have data like this from a file&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;1 abcdefgh bil&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nigeria&amp;nbsp; &amp;nbsp; &amp;nbsp;$999.5B&amp;nbsp; &amp;nbsp;$99.1B&amp;nbsp; &amp;nbsp;$789.1B&amp;nbsp; &amp;nbsp;$123.4B&amp;nbsp; $235.2B&amp;nbsp; $9089.1B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using data step to read this data , below is my code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dsbig ;&lt;BR /&gt;infile 'c:\big.dat' ;&lt;BR /&gt;input rank :3. cmpname :&amp;amp;$26. country :&amp;amp;$15. sales :dollar5.1 +1 profit :dollar5.1 +1 asst :dollar5.1 +1 mktval :dollar5.1 +1 fldval1 :dollar5.1 +1 fldval2 :dollar5.1 +1 ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;I am not able to read the numeric data with dollar signs at all whereas the character data is being read properly .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried options like dollar.&amp;nbsp; ,&amp;nbsp; comma5.1 , comma., but nothing seems to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The question is how to specify informat for numeric data that have $ signs attached to it ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;jana&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 05:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490322#M128251</guid>
      <dc:creator>ariyurjana</dc:creator>
      <dc:date>2018-08-28T05:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to specify informat  for numeric values with $ sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490323#M128252</link>
      <description>&lt;P&gt;Your problem is not the dollar sign, but the "B". What does it mean?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 05:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490323#M128252</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-28T05:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to specify informat  for numeric values with $ sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490325#M128254</link>
      <description>&lt;P&gt;&lt;SPAN&gt;$999.5B informat will fail bcoz of B in value. Do you wanna keep B in value?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if not read as char and strip the char part and convert to numeric&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 05:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490325#M128254</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-28T05:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to specify informat  for numeric values with $ sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490337#M128262</link>
      <description>&lt;P&gt;It specifies that the values are in billions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;jana&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 06:09:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490337#M128262</guid>
      <dc:creator>ariyurjana</dc:creator>
      <dc:date>2018-08-28T06:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to specify informat  for numeric values with $ sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490338#M128263</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No I dont want the "B". to skip that "B" I am using +1 in the input statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$433.5B for this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for&amp;nbsp;$433.5 the format is dollar5.1&lt;/P&gt;&lt;P&gt;for B i am using +1 to skip that value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;jana&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 06:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490338#M128263</guid>
      <dc:creator>ariyurjana</dc:creator>
      <dc:date>2018-08-28T06:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to specify informat  for numeric values with $ sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490339#M128264</link>
      <description>&lt;P&gt;If all those values (all columns, all rows) will contain a B, you can use the compress function to get rid of them:&lt;/P&gt;
&lt;P&gt;- read into a character variable&lt;/P&gt;
&lt;P&gt;- remove the B with compress()&lt;/P&gt;
&lt;P&gt;- read into numeric with the input() function&lt;/P&gt;
&lt;P&gt;- drop the character variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might make sense to pack all of these actions into a macro, so you have to write and maintain the code only once. But first you have to get it to work for one of the columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If other characters might also appear, you have to account for those (set a multiplier conditionally)&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 06:16:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490339#M128264</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-28T06:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to specify informat  for numeric values with $ sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490340#M128265</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will the idea of reading up to the last decimal point and using a +1 to skip the "B" not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;jana&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 06:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490340#M128265</guid>
      <dc:creator>ariyurjana</dc:creator>
      <dc:date>2018-08-28T06:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to specify informat  for numeric values with $ sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490342#M128266</link>
      <description>&lt;P&gt;No. The +1 moves the column pointer before an item is read, it can't be reliably used to split column text. Note that you have columns of different lengths (the last one is too big for the $5.1 informat).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See this example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro read_item(varname);
input _&amp;amp;varname. :$10. @;
&amp;amp;varname. = input(compress(_&amp;amp;varname.,'B'),dollar10.);
format &amp;amp;varname. dollar10.1;
drop _&amp;amp;varname.;
%mend;

data dsbig;
input rank :3. cmpname :&amp;amp;$26. country :&amp;amp;$15. @;
%read_item(sales);
%read_item(profit);
%read_item(asst);
%read_item(mktval);
%read_item(fldval1);
%read_item(fldval2);
cards;
1 abcdefgh bil                  nigeria     $999.5B   $99.1B   $789.1B   $123.4B  $235.2B  $9089.1B
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that you must not use decimals in informats &lt;EM&gt;unless&lt;/EM&gt; you need to &lt;EM&gt;force&lt;/EM&gt; the number of decimals for numbers that don't contain a decimal point. The dollar10. informat will find the decimal point on its own and act accordingly. dollar10.1, OTOH, would convert an input value of $9999 to 999.9, which is not what you want.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 06:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490342#M128266</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-28T06:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to specify informat  for numeric values with $ sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490345#M128269</link>
      <description>&lt;P&gt;Wonderful worked like a charm without any modifications.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 07:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-specify-informat-for-numeric-values-with-sign/m-p/490345#M128269</guid>
      <dc:creator>ariyurjana</dc:creator>
      <dc:date>2018-08-28T07:03:02Z</dc:date>
    </item>
  </channel>
</rss>

