Aldi,

Is this what you want?

data a1;
   input id1 y1 y2;
     datalines;
123 12 10
123 13 13
125 14 20
;

options nocenter;
proc sql;
select *, mean(y1) as y1m, mean(y2) as y2m,
      (y1-calculated y1m)*(y2-calculated y2m) as crp
from a1
;

---------------


     ID1        Y1        Y2       Y1M       Y2M       CRP
----------------------------------------------------------
     123        12        10        13  14.33333  4.333333
     123        13        13        13  14.33333         0
     125        14        20        13  14.33333  5.666667

Ya Huang

-----Original Message-----
From: Aldi Kraja [mailto:aldi@wubios.wustl.edu]
Sent: Wednesday, January 10, 2001 2:45 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Any better way...?


Hi,

Here is a simple question for a better way of doing the following:

I have a group of data with two Y1 and Y2. I want to produce a corrected
cross product.

At the end is an example how I think can be resolved the problem, but to
me it looks that I am having to many steps in this part of the program.
Is there any other quicker way of resolving it? (The data set is huge,
therefore I am trying to save computer time).

TIA,
Aldi

P.S. data and solution:

data a1;
   input id1 y1 y2;
     datalines;
123 12 10
123 13 13
125 14 20
;
proc means data=a1;
   var y1 y2;
    output out=a4 mean=y1mean y2mean;
run;
data _null_;
    set a4;
      call symput("r1",y1mean);
      call symput("r2",y2mean);
run;

%macro d1;
data a2;
    set a1;
     y1m=%eval(&r1);
     y2m=%eval(&r2);
crp=(y1-y1m)*(y2-y2m);
run;
%mend d1;
%d1
--