BookmarkSubscribeRSS Feed
sks
Fluorite | Level 6 sks
Fluorite | Level 6

Hello,

    I have a requirement to display negative currency in paranthesis. So I am using a custom format. Here is how the format is

created

proc format lib=sasrepo;

picture DollarParen low -  -1  =  '000,000,000,000.00)' (prefix='($')

           -1 <-<  0  =     '99)' (prefix='($0.' mult=100)

            0  -< 1   =     '99'  (prefix='$0.'  mult=100)

            1  - high =  '000,000,000,000.00' (prefix='$');

run;

My field has the number -142663408.917

when I use the Dollar format, the field displays as -142663408.92  which is correct.

but when I use the custom format I get

($142663408.91). For some reason the custom format is stripping the last digit. Even if I round the number

round(-142663408.917,.01) and then apply the custom format I still get the field to display ($142663408.91)

Can you please look at the custom format and let me know what I need to do to get the right dispaly. I need the negative currency

amounts to display in paranthesis and rounded to 2 digit.

Thank You

Shri

4 REPLIES 4
data_null__
Jade | Level 19

I believe you need the ROUND option...

picture DollarParen(round)

sks
Fluorite | Level 6 sks
Fluorite | Level 6

Thanks,

    I changed the format to be

proc format lib=sasrepo;

picture DollarParen round((low -  -1  =  '000,000,000,000.00)' (prefix='($')

           -1 <-<  0  =     '99)' (prefix='($0.' mult=100)

            0  -< 1   =     '99'  (prefix='$0.'  mult=100)

            1  - high =  '000,000,000,000.00' (prefix='$')),.01);

run;

But I am getting the error

Syntax error, expecting one of the following: a quoted string, a numeric constant,

a datetime constant, a missing value, ;, (, LOW, OTHER.

Can you please tell me where the round should be??

data_null__
Jade | Level 19

Just like in my example

picture picture_name(picture_options) and the rest.

Do you have access to the SAS help facility?

Ksharp
Super User

_null_ is right.try this:

proc format ;
picture DollarParen(default=20 round) 
           low -  -1  =  '000,000,000,000.00)' (prefix='($')
           -1 <-<  0  =     '99)' (prefix='($0.' mult=100)
            0  -< 1   =     '99'  (prefix='$0.'  mult=100)
            1  - high =  '000,000,000,000.00' (prefix='$');
run; 

Ksharp

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1531 views
  • 0 likes
  • 3 in conversation