BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
braam
Quartz | Level 8

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
Cynthia_sas
Diamond | Level 26

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_sas_0-1597588707308.png

 

Cynthia

View solution in original post

3 REPLIES 3
Norman21
Lapis Lazuli | Level 10

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

data_null__
Jade | Level 19

Why not use a DEFINE statement?

 

define mean / format=8.3;
Cynthia_sas
Diamond | Level 26

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_sas_0-1597588707308.png

 

Cynthia

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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