
102 Handbook of SAS
®
DATA Step Programming
by id;
array all_g[2,3] $ m_g1 − m_g3 f_g1 − f_g3;
array g[3];
retain all_g;
if first.id then i = 0;
i + 1;
do j = 1 to 3;
all_g[i,j] = g[j];
end;
if last.id;
run;
Program 6.12 transforms data set DAT2 back to data set DAT1. The thinking
behind Program 6.12 is similar to Program 6.11. A one-dimensional array,
G[3], is used to create variables G1–G3. A two-dimensional array, ALL_G[2,3],
is used to group the existing variables M_G1, M_G2, M_G3, F_G1, F_G2,
andF_G3. The nested loop is used to create variables G1–G3. The OUTPUT
statement that follows the inner loop is needed to create ...