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

I am working with the default CARS data set in SAS Studio, and want to examine the difference in mean horsepower between car manufacturers. The image/code below is my simple Summary Statistics program.

 

https://prnt.sc/20kfe5g

ods noproctitle;
ods graphics / imagemap=on;

proc means data=SASHELP.CARS chartype mean std vardef=df;
	var Horsepower;
	class Make;
run;

As you can see, the output is organized by make. This would be fine if I were only interested in a single make, but the large number of manufacturers makes it difficult to examine the order of all at once. I need to sort the output table by Mean. How do I do it?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You cannot control the displayed output at that level unfortunately. 

 

You can save the output to a data set (click on the OUTPUT tab and check the box and select the stats). 

Then you can sort/re-order the output data set as desired. 

 


@brush01 wrote:

I am working with the default CARS data set in SAS Studio, and want to examine the difference in mean horsepower between car manufacturers. The image/code below is my simple Summary Statistics program.

 

https://prnt.sc/20kfe5g

ods noproctitle;
ods graphics / imagemap=on;

proc means data=SASHELP.CARS chartype mean std vardef=df;
	var Horsepower;
	class Make;
run;

As you can see, the output is organized by make. This would be fine if I were only interested in a single make, but the large number of manufacturers makes it difficult to examine the order of all at once. I need to sort the output table by Mean. How do I do it?


 

View solution in original post

2 REPLIES 2
Reeza
Super User

You cannot control the displayed output at that level unfortunately. 

 

You can save the output to a data set (click on the OUTPUT tab and check the box and select the stats). 

Then you can sort/re-order the output data set as desired. 

 


@brush01 wrote:

I am working with the default CARS data set in SAS Studio, and want to examine the difference in mean horsepower between car manufacturers. The image/code below is my simple Summary Statistics program.

 

https://prnt.sc/20kfe5g

ods noproctitle;
ods graphics / imagemap=on;

proc means data=SASHELP.CARS chartype mean std vardef=df;
	var Horsepower;
	class Make;
run;

As you can see, the output is organized by make. This would be fine if I were only interested in a single make, but the large number of manufacturers makes it difficult to examine the order of all at once. I need to sort the output table by Mean. How do I do it?


 

Ksharp
Super User
proc sql;
select Make,count(Horsepower) as n label='Nobs',
       mean(Horsepower) as mean label='Mean',
    std(Horsepower) as std label='Stddev'
 from sashelp.cars
  group by Make
   order by mean desc;
quit;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 506 views
  • 1 like
  • 3 in conversation