turn on suggestions

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

Showing results for

Find a Community

- Home
- /
- BI
- /
- Enterprise Guide
- /
- Format 1,000,000 to display1.0

Topic Options

- 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-04-2014 10:55 AM

Hello,

In SAS Enterprise Guide, how can I change a column to display to the "thousandth"? For example, if a number is $2,534,000 - I would like the result to show $2.534.

I know I can divide a column by 100,000 but there are 60 columns and I don't want to do that for all 60 columns.

Thanks!

Accepted Solutions

Solution

08-04-2014
03:14 PM

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

Posted in reply to jen123

08-04-2014 03:14 PM

I think you need to consider these two Cautions from the documentation.

CAUTION:

The picture must be wide enough for the prefix and the numbers.

In this example, if the value –45.00 were formatted with NOZEROS., then the result would be 45.00 because it falls into the first range, low – –1, and the picture for that range is not wide enough to accommodate the prefixed minus sign and the number.

CAUTION:

The picture must be wide enough for an additional digit if rounding a number adds a digit to the number.

For example, the picture for the number .996 could be ‘99’ (prefix ‘.’ mult=100). After rounding the number and multiplying it by 100, the resulting number is 100. When the picture is applied, the result is .00, an inaccurate number. In order to ensure accuracy of numbers when you round numbers, make the picture wide enough to accommodate larger numbers.

picture million(round)

a =

b =

c =

d =

x =

y =

format _all_ million. ;

put (_all_)(=best.);

put (_all_)(=million.);

a=49999 b=70000 c=100000 d=1000000 x=19875000 y=200000000

a=$0.0 b=$0.1 c=$0.1 d=$1.0 x=$19.9 y=$200.0

All Replies

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

Posted in reply to jen123

08-04-2014 11:06 AM

Well you could try using arrays:

data want;

set have;

/* Way 1 where columns not the same = array myarray{60} var1 var2 var3 etc. - long winded */

array var{60}; /* This assumes the variables are named var1 var2 etc. */

do I=1 to 60;

var{I}=var{I}/100000;

end;

run;

Alternatively you could generate the either by macro or call execute.

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

Posted in reply to jen123

08-04-2014 11:35 AM

This can be done with a PICTURE FORMAT and the appropriate multiplier applied to the range. See the documentation I believe there is an example that is just what you are looking for or very close.

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

Posted in reply to jen123

08-04-2014 11:37 AM

You probably have a numeric dollar format that has a format applied to that showing the $ ...... SAS(R) 9.4 Formats and Informats: Reference

With proc format you can define your own one with a multiply-factor. Just change the formats not the data. Base SAS(R) 9.4 Procedures Guide, Second Edition

---->-- ja karman --<-----

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

Posted in reply to jakarman

08-04-2014 12:41 PM

Hi:

Data_Null and Jaap are recommending the right way to deal with this issue -- changing the data is unnecessary. PROC FORMAT will do this for you and the documentation has an example of creating the "BIGMONEY." format for an example such as yours: Base SAS(R) 9.4 Procedures Guide, Second Edition (The example is entitled "Example 3: Creating a Picture Format for Large Dollar Amounts").

cynthia

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

Posted in reply to Cynthia_sas

08-04-2014 02:21 PM

Thanks everyone for the responses. Cynthia - thanks for the link to the Big Money example. That helped, but I stil lhave an issue. Here is my code. The format works for x and y. However, a, b and c do not. I should get:

a = $0.0

b = $.01

c= $.01

Instead I get:

a= $99.0

b= $1

c=$1

Your assistance is greatly appreciated!

********************

proc format;

picture million (round fuzz=0)

0 -< 50000 = '00.0' (prefix='$' mult=0.0)

50000 -< 1000000 = '00.0' (prefix='$' mult=0.00001)

1000000 -< 1000000000='0000.0' (prefix='$' mult=.00001);

run;

data null ;

a = 49999;

b = 70000;

c = 100000;

x = 19875000 ;

y = 200000000;

format a million. ;

format b million. ;

format c million. ;

format x million. ;

format y million. ;

run ;

Solution

08-04-2014
03:14 PM

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

Posted in reply to jen123

08-04-2014 03:14 PM

I think you need to consider these two Cautions from the documentation.

CAUTION:

The picture must be wide enough for the prefix and the numbers.

In this example, if the value –45.00 were formatted with NOZEROS., then the result would be 45.00 because it falls into the first range, low – –1, and the picture for that range is not wide enough to accommodate the prefixed minus sign and the number.

CAUTION:

The picture must be wide enough for an additional digit if rounding a number adds a digit to the number.

For example, the picture for the number .996 could be ‘99’ (prefix ‘.’ mult=100). After rounding the number and multiplying it by 100, the resulting number is 100. When the picture is applied, the result is .00, an inaccurate number. In order to ensure accuracy of numbers when you round numbers, make the picture wide enough to accommodate larger numbers.

picture million(round)

a =

b =

c =

d =

x =

y =

format _all_ million. ;

put (_all_)(=best.);

put (_all_)(=million.);

a=49999 b=70000 c=100000 d=1000000 x=19875000 y=200000000

a=$0.0 b=$0.1 c=$0.1 d=$1.0 x=$19.9 y=$200.0

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

Posted in reply to data_null__

08-13-2014 12:20 PM

This thread and the BIGMONEY example prompted me to complete this blog post, which I had been mulling for a while:

Format your data like a social media superstar - The SAS Dummy

SAS formats are super powerful, and PICTURE formats can be immensely useful. Enjoy!

Chris