BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

I'm trying to format a numeric to dollar8.2

Here is the situation:
I've the numeric 1667328.6879

I'm trying to use format=dollar8.2
I want the result to be $1667328.68

But the result just shows 1667328 (no $ sign neither decimal points)

Thanks, I'm new to SAS trying to understand this.
4 REPLIES 4
Pavan_SAS
SAS Employee
use this format !

dollar11.2

it will work !
deleted_user
Not applicable
hi san@sas,

give ur mail id.

i wll send sas basics to ur id.


help@sas.
Olivier
Pyrite | Level 9
Hi San.
The thing to understand with figures in format names is that :
- the first figure (8 in dollar8.2) is for the TOTAL number of characters needed to display the value, including all special signs aside from the digits themselves : dollar sign, decimal point, comma, percent sign (which counts for three : remember it as if it were displayed o/o), minus sign, and so on...
- the second figure (2 in dollar 8.2) is the number of decimals. It is honored only if there is enough room left by the total length given by the first figure.

So when you say you want to use DOLLAR8.2, that means that you can display on 8 characters, including a dollar sign and a decimal point : $xxxx.xx ; so you cannot display this way numbers larger than 9999.99. If you wan to display 10000 then the format will stick to th most important information, the total length, and reduce the number of decimals to display on 8 characters : $10000.0.
With 1667328.6879, the only way to honor the total length of 8 is to discard decimals and dollar sign. Hence your result.
As Pavan said, you need to increase the total length to display the number properly. Do not hesitate to use big lengths in a first place, to make sure you can display all digits, and in a second time you can use smaller lengths. In that case, any length larger than 11 will be fine : DOLLAR15.2 for example will be also correct.
Regards
Olivier
deleted_user
Not applicable
Thanks all

I got the solution

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

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