Compute average of m variables where m is a variable in the data file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * Compute avg of m varaibles where m is a variable in the data file. * in the example m is gmplans. Thus in second case (gmplans=2) we want the average of the first two variables, that is variables fpr_iy1 and fpr_ip2. * Raynald Levesque Feb 2004. * http://pages.infinit.net/rlevesqu/index.htm NEW FILE. DATA LIST LIST /gmplans fpr_iy1 TO fpr_iy4. BEGIN DATA 1 4 3 2 1 2 4 3 2 1 3 4 3 2 1 4 4 3 2 1 0 4 3 2 1 END DATA. VECTOR v1 = fpr_iy1 TO fpr_iy4 . LOOP #i = 1 TO gmplans. - DO IF #i=1. - COMPUTE min_ind = v1(#i) . - ELSE. - COMPUTE min_ind=MIN(min_ind, v1(#i)). - END IF. END LOOP . DESCRIPTIVES VARIABLES=min_ind /STATISTICS=MEAN STDDEV MIN MAX . |
Related pages
...