DATA Step, Macro, Functions and more

Custom format issues

Reply
Contributor sks
Contributor
Posts: 42

Custom format issues

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

Respected Advisor
Posts: 3,777

Re: Custom format issues

I believe you need the ROUND option...

picture DollarParen(round)

Contributor sks
Contributor
Posts: 42

Re: Custom format issues

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??

Respected Advisor
Posts: 3,777

Re: Custom format issues

Just like in my example

picture picture_name(picture_options) and the rest.

Do you have access to the SAS help facility?

Super User
Posts: 9,662

Re: Custom format issues

_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

Ask a Question
Discussion stats
  • 4 replies
  • 172 views
  • 0 likes
  • 3 in conversation