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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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