Proc means "By" statement

Posts: 35

Proc means "By" statement

Hi all,

Suppose i want to use two variables in "BY statement " for proc means procedure , then the file sorted is required on which variable .

Can i work with sorted file on variable AGE or do i need to sort on both the variables.

the current file" Prac.sortr" is sorted on AGE .

I got an error while executing this program.

Could someone solve this....

For eg..

proc means DATA=Prac.sortr mean;

var SX1 SX2;

by AGE S4;


Super Contributor
Posts: 644

Re: Proc means "By" statement


Include S4 in your Proc sort by variables (just the same as for the proc means)


Put s4 in a separate class statement in Proc means (you probably should have either a print option or an output dataset)

proc means DATA=Prac.sortr mean print;

var SX1 SX2;

by AGE ;

class S4;


If this does not answer your question please copy the error statement from the log.


Super User
Posts: 13,523

Re: Proc means "By" statement

In general BY processing requires the data to be sorted by all of the variables in the by statement and in that order. HINT: the BY statement in both Proc Sort and the procedure will be the same.

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation