home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / bit / listserv / sasl / 3529 < prev    next >
Encoding:
Text File  |  1992-07-31  |  2.8 KB  |  80 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!paladin.american.edu!auvm!SWIRL.MONSANTO.COM!GIBES
  3. Message-ID: <9207311828.AA22390@tin.monsanto.com>
  4. Newsgroups: bit.listserv.sas-l
  5. Date:         Fri, 31 Jul 1992 13:28:47 -0500
  6. Reply-To:     Kernon Gibes <gibes@SWIRL.MONSANTO.COM>
  7. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  8. From:         Kernon Gibes <gibes@SWIRL.MONSANTO.COM>
  9. Subject:      RE: more on nesting data steps
  10. Comments: To: SAS-L@uga.cc.uga.edu@tin.monsanto.com
  11. Comments: cc: GIBES@tin.monsanto.com
  12. Lines: 66
  13.  
  14.  CONTENT:   Response (to "more on nesting data steps")
  15.  SUMMARY:   Try SET ... POINT= for all possible pairs in a data step
  16.  REL/PLTF:  n.a.
  17.  E-ADDR:    gibes@swirl.monsanto.com
  18.  NAME:      Kernon Gibes
  19.  PHONE:     (708) 506-2873
  20.  DATE:      31 July 1992
  21.  
  22.  I'm going to take a crack at the two postings on "concurrent sas data
  23.  steps" and "more on nesting data steps".  No flames please.  I fully
  24.  realize that I'm doing some MAJOR guessing here.  My intent is not so
  25.  much to answer the question as to provoke further clarification.  (I
  26.  don't know who the requestor is).
  27.  
  28.  ASSUMING that all your data is actually in a data set called RAW with
  29.  variables VAR1 to VAR&P (&P = 3 below) and one observation per person
  30.  and ASSUMING that the summary statistics computed for the i-th person
  31.  by all others can be computed without IML code, then a rough sketch of
  32.  an approach using the data set POINT is outlined below.  Of course, the
  33.  later assumption is, I think, quite crucial.  I'm presuming that the
  34.  requestor can either see how to generalize the fake stats I'm doing or
  35.  see why this approach won't work and explain futher requirements.
  36.  
  37.  /*** define a macro needed for the data step ***/
  38.  %macro rename;
  39.   RENAME=(
  40.     %do i = 1 %to &p;
  41.       var&i = _var&i
  42.     %end;
  43.    )
  44.  %mend rename;
  45.  
  46.  %let P=3;
  47.  
  48.  data stats;
  49.   array vector_i {*} var1-var&p;
  50.   array vector_j {*} _var1-_var&p;
  51.  
  52.   do i=1 to N;
  53.      /*** do summary stats for i, over N-1 pairings
  54.           (zero out i-th summary stats) ***/
  55.      sumcp = 0;
  56.      ssqcp = 0;
  57.      do j=1 to N;
  58.       if i ne j then do;
  59.          /*** load in data for i-th person ***/
  60.         set raw nobs=N point=i;
  61.         outid =id;
  62.          /*** load in data for j-th person ***/
  63.         set raw( %rename ) point=j;
  64.          /*** do summary stats for i, j data pairing
  65.               (zero out summary stats for P by P computations) ***/
  66.         cp = 0;
  67.         do k = 1 to &p;
  68.            cp = cp + vector_i[k] * vector_j[k];
  69.         end;
  70.          /*** do summary stats for N-1 pairings with the i-th person**/
  71.         sumcp = sumcp + cp;
  72.         ssqcp = ssqcp + cp*cp;
  73.       end;
  74.      end;
  75.      output;  /*** only need global stats for each person ***/
  76.   end;
  77.   stop;  /*** VERY necessary ***/
  78.  keep outid var1-var&p sumcp ssqcp;
  79.  run;
  80.