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.
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
The technique described here might be worth trying:
https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p089-26.pdf
Why not use a DEFINE statement?
define mean / format=8.3;
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.