Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- using format=dollarx.x

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-11-2008 01:22 AM

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.

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

08-11-2008 01:43 AM

use this format !

dollar11.2

it will work !

dollar11.2

it will work !

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Pavan_SAS

08-11-2008 01:54 AM

hi san@sas,

give ur mail id.

i wll send sas basics to ur id.

help@sas.

give ur mail id.

i wll send sas basics to ur id.

help@sas.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

08-11-2008 02:49 AM

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

08-12-2008 02:34 AM

Thanks all

I got the solution

I got the solution