DATA Step, Macro, Functions and more

using format=dollarx.x

Reply
N/A
Posts: 0

using format=dollarx.x

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.
SAS Employee
Posts: 73

Re: using format=dollarx.x

Posted in reply to deleted_user
use this format !

dollar11.2

it will work !
N/A
Posts: 0

Re: using format=dollarx.x

Posted in reply to Pavan_SAS
hi san@sas,

give ur mail id.

i wll send sas basics to ur id.


help@sas.
Super Contributor
Posts: 260

Re: using format=dollarx.x

Posted in reply to deleted_user
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
N/A
Posts: 0

Re: using format=dollarx.x

Posted in reply to deleted_user
Thanks all

I got the solution
Ask a Question
Discussion stats
  • 4 replies
  • 168 views
  • 0 likes
  • 3 in conversation