<?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: -$160    instead of  $-160 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388260#M93107</link>
    <description>&lt;P&gt;And if you need something more robust to apply a real currency format, you could test for different currency "unit" values and apply the proper formats according to the regional conventions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
 length unit $ 3 amount 8;
 infile datalines;
 input unit amount;
 datalines;
$ -162
$ -398
$ 160
GBP -162
GBP -398
GBP 160
€ -162
€ -398
€ 160
;
run;

data formatted;
 set test;
 select (unit);
  when ('$')  price = put(amount,dollar10.);
  when ('GBP')  price = put(amount,NLMNLGBP10.);
  when ('€')  price = put(amount,NLMNLEUR10.); /* or EURO10. */
  otherwise price=put(amount,dollar10.);
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fmtcurrency.png" style="width: 202px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14501iE34C4499671A05AC/image-size/large?v=v2&amp;amp;px=999" role="button" title="fmtcurrency.png" alt="fmtcurrency.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(I don't know why the euro symbol isn't showing in records 7 and 8...but you get the idea, I hope.)&lt;/P&gt;</description>
    <pubDate>Tue, 15 Aug 2017 18:54:23 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2017-08-15T18:54:23Z</dc:date>
    <item>
      <title>-$160    instead of  $-160</title>
      <link>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388247#M93104</link>
      <description>&lt;P&gt;I have two column :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;UNIT&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Amount&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;$&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;-162&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;$&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;-398&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;$&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;160&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i concatenate My amount is coming as $-160 , but i want it to come as -$160&amp;nbsp;.&lt;/P&gt;&lt;P&gt;however if it positive no then it should come like $160&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 18:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388247#M93104</guid>
      <dc:creator>subrat1</dc:creator>
      <dc:date>2017-08-15T18:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: -$160    instead of  $-160</title>
      <link>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388255#M93105</link>
      <description>&lt;P&gt;somthing like this should work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input UNIT $ Amount;
datalines;
$ -162 
$ -398 
$ 160
;



proc sql;
select case when amount lt 0
 then '-'||strip(unit)||strip(put(abs(amount),5.))
 else strip(unit)||strip(put(amount,5.))
 end as newcol
 from have;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Aug 2017 18:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388255#M93105</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-08-15T18:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: -$160    instead of  $-160</title>
      <link>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388258#M93106</link>
      <description>&lt;P&gt;Since the problem involves changing a string into another string, you could use regular expression substitution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input amount $;
dollarAmount = prxchange("s/([.0-9])/\$\1/",1,amount);
datalines;
-162
-398
160
;

proc print noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Aug 2017 18:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388258#M93106</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-08-15T18:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: -$160    instead of  $-160</title>
      <link>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388260#M93107</link>
      <description>&lt;P&gt;And if you need something more robust to apply a real currency format, you could test for different currency "unit" values and apply the proper formats according to the regional conventions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
 length unit $ 3 amount 8;
 infile datalines;
 input unit amount;
 datalines;
$ -162
$ -398
$ 160
GBP -162
GBP -398
GBP 160
€ -162
€ -398
€ 160
;
run;

data formatted;
 set test;
 select (unit);
  when ('$')  price = put(amount,dollar10.);
  when ('GBP')  price = put(amount,NLMNLGBP10.);
  when ('€')  price = put(amount,NLMNLEUR10.); /* or EURO10. */
  otherwise price=put(amount,dollar10.);
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fmtcurrency.png" style="width: 202px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14501iE34C4499671A05AC/image-size/large?v=v2&amp;amp;px=999" role="button" title="fmtcurrency.png" alt="fmtcurrency.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(I don't know why the euro symbol isn't showing in records 7 and 8...but you get the idea, I hope.)&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 18:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388260#M93107</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-08-15T18:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: -$160    instead of  $-160</title>
      <link>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388274#M93108</link>
      <description>&lt;P&gt;Strangely enough, I don't get the same result with my version of SAS (and/or locale)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;                       Obs    unit    amount      price

                         1     $        -162          $-162
                         2     $        -398          $-398
                         3     $         160           $160
                         4     GBP      -162     (162,00 £)
                         5     GBP      -398     (398,00 £)
                         6     GBP       160      160,00 £
                         7     €        -162     (162,00 €)
                         8     €        -398     (398,00 €)
                         9     €         160      160,00 €
&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Aug 2017 19:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388274#M93108</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-08-15T19:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: -$160    instead of  $-160</title>
      <link>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388282#M93109</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp; - the NL* formats are meant to be locale-sensitive, so if you're running in French Canadian, that might be different than my English-US.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 19:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/160-instead-of-160/m-p/388282#M93109</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-08-15T19:53:41Z</dc:date>
    </item>
  </channel>
</rss>

