You're trying to do too much in a single DATA step. Most every DOW loop will use the same groupings in both DO loops. For example, have the top loop read all observations for a DIS PerformanceLevel combination, computing a summary statistic. Then use the bottom DO loop to re-read the exact same observations, appending those summary statistics to every observation in the group.
To take an example, suppose you wanted the 5 sums appended to every observation for that DIS PerformanceLevel combination. You could use:
data setloop3;
do until (last.PerformanceLevel); set setloop2;
by Dis PerformanceLevel; sumPL1=sum(sumPL1,PL1); sumPL2=sum(sumPL2,PL2); sumPL3=sum(sumPL3,PL3); sumPL4=sum(sumPL4,PL4); sumPL5=sum(sumPL5,PL5); end; do until (last.PerformanceLevel); set setloop2; by Dis PerformanceLevel; output; end; run;
Now the 5 sum variables contain subtotals for the DIS PerformanceLevel combination, but those 5 subtotals become part of every observation.
... View more