Question

Say I have a dataset with 3 variables. It looks like:

Var1   Var2   Var3
   1      1     4
   1      2     5
   1      3     1
   2      1     6
   2      2     2
   2      3     8
   3      1     2
   3      2     7
   3      3     9 

How can I find the mean of Var3 for each "group" it is in? (4, 5, 1 from Var3 have 1 from Var1 in common, 6,2,8 with 2 etc)? Would using a where expression work and would I be able to loop it over values like in Var1?

Was it helpful?

Solution

I think you can just use the CLASS option to proc means or similar. E.g.:

PROC MEANS DATA=DAT MEAN;
  CLASS Var1;
  VAR   Var3;
run; 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top