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;