Proc means "By" statement

Reply
Contributor
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;

run;

Super Contributor
Posts: 644

Re: Proc means "By" statement

Either

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

Or

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;

run;

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

Richard

Super User
Posts: 10,500

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
  • 161 views
  • 0 likes
  • 3 in conversation