Quartz | Level 8

## Number formatting in PROC REPORT

Hi All,

I would like to handle all numbers with decimal points at once in PROC REPORT. My code is as follows.

``````
proc report data= sashelp.cars out= out;
columns make EngineSize, (n mean) Cylinders , (n mean) Horsepower , (n mean) ;
define make / group;
run;``````

The contents of the output look fine, but digits are poorly formatted. Some numbers have seven decimal points. Is there a way for me to handle this to display like this?

WHAT I HAVE NOW

Engine Size (L) Cylinders Horsepower
Make n mean n mean n mean
Acura 7 3.0428571 7 5.4285714 7 239.28571
Audi 19 3.0578947 19 6.1052632 19 250.78947
BMW 20 3.125 20 6.4 20 241.45

WHAT I WANT TO HAVE

Engine Size (L) Cylinders Horsepower
Make n mean n mean n mean
Acura 7 3.04 7 5.43 7 239.29
Audi 19 3.06 19 6.11 19 250.79
BMW 20 3.13 20 6.40 20 241.45

Just to be sure: I found two solutions, but they are not so efficient because I use this procedure really a lot to inspect my data.

1) proc report with many DEFINE statements to get each mean formatted. If I have ten variables to display, I should have 10 define statements, which I would like to avoid.

2) Handling the output set generated from PROC REPORT. It may be better, but I noticed that the output statement gives me weird variable names such as _C3_, _C4_, etc.

In addition, I usually display N and Mean. But I sometimes would like to see many other summary stat like p50, etc. Hence, I just would like to know if there is a way to handle formats of all numbers displayed in PROC REPORT.

1 ACCEPTED SOLUTION

Accepted Solutions
SAS Super FREQ

## Re: Number formatting in PROC REPORT

Hi:

Exactly as  @Data_null_ explained. Since you are using a KEYWORD statistic with multiple variables, you can simply format the statistic with 1 DEFINE statement.

Cynthia

3 REPLIES 3
Lapis Lazuli | Level 10

## Re: Number formatting in PROC REPORT

The technique described here might be worth trying:

https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p089-26.pdf

Norman.
SAS 9.4 (TS1M6) X64_10PRO WIN 10.0.17763 Workstation

## Re: Number formatting in PROC REPORT

Why not use a DEFINE statement?

``define mean / format=8.3;``
SAS Super FREQ

## Re: Number formatting in PROC REPORT

Hi:

Exactly as  @Data_null_ explained. Since you are using a KEYWORD statistic with multiple variables, you can simply format the statistic with 1 DEFINE statement.

Cynthia

Discussion stats
• 3 replies
• 770 views
• 4 likes
• 4 in conversation