SAS (Base SAS)+
data loop;
do treatment=1,3,5;
do avisitn=0,1,2,8;
output;
end;
end;
run;- To build a dummy dataset with every combination of a set of values, we reach for a nested
DOloop with anOUTPUTstatement in between. - The outer loop iterates over treatments (1, 3, 5) and the inner loop over visit numbers (0, 1, 2, 8).
- The
output;statement inside the inner loop writes one observation for every combination — 3 x 4 = 12 rows. - Without an explicit
output, SAS would only write a row at the end of each DATA step iteration; with it, we get a full cross-product. - This is the quickest way to prototype a skeleton dataset for testing — for example, a subject-by-visit grid before actual data is available.
- After running, we check that
loophas 12 rows with everytreatment-avisitnpair appearing exactly once.