an interesting aproach can reduce the code, by depending upon some less obvious features of a data step.
The requirement here is simple, and so is the resulting code that follows:[pre]DATA AA( drop= CODE );
ARRAY DD {15} $ CODE1-CODE15;
do i=1 to 15 until( last.ID ) ;
SET BB;
BY ID;
DD{I} = CODE;
end ;
RUN; [/pre]
The SET statement is
within the DO loop that terminates at the end of each by-group.
Because the set statement is within the loop, the array elements do not need to be retained. So, the array elements will be reset to missing as each data step iteration starts
On exiting the DO loop the default behaviour of a data step releases the observation without an OUTPUT statement.
The technique of placing a set/merge within an explicit DO loop to take advantage of the initialisation and "temporary retention" of non-retained variables and/or FIRST-, LAST- by-group processing, while reducing the granularity of the data, has been described as a DoW loop. There have been quite a few papers describing this technique on recent SUGI and SAS Global Forums (presumeably also regional and local user groups too).
www.lexjansen.com provides an effective search engine.
Definitely worth a read..
PeterC