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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2489 views
  • 0 likes
  • 3 in conversation