Just a short code snippet to illustrate how one could write the contents of an array to a dataset; note that the dataset in question is always named in the data ...; statement.
data test1 (drop=i j);
array x{2,3};
do i = 1 to 2;
do j = 1 to 3;
x{i,j} = i*j;
end;
end;
run;
proc print noobs;
run;
data test2 (keep=i j value);
array x{2,3};
do i = 1 to 2;
do j = 1 to 3;
x{i,j} = i*j;
value = x{i,j};
output;
end;
end;
run;
proc print noobs;
run;
This creates the following outputs:
x1 x2 x3 x4 x5 x6
1 2 3 2 4 6
i j value
1 1 1
1 2 2
1 3 3
2 1 2
2 2 4
2 3 6
Also note that no input dataset was involved, which means both data steps underwent only 1 iteration. With an input dataset, everything would be repeated for each observation in the dataset.
If you wanted to create a separate dataset for eacjh input observation, more complicated programming would be necessary; I could imagine solving that with the use of a hash object.
... View more