You could either do it with FIRST.byvar and LAST.byvar in a datastep. Every time you read a new obs, you could concatenate that obs value for comment onto a new comment variable whose value would be retained until you got to the last obs of the group.
Or, you could use PROC TRANSPOSE by L_NAME to get the comments all on one obs and then just concatenate all the 5 possible comments together.
One possible transpose solution is shown below.
** Read data and make an "origord" var;
** to keep comments in the order they appeared in;
** the original input data.;
length l_name $25 comment $30;
input l_name & $ comment & $;
origord = _n_;
Smith One Fish
Smith Two Fish
Smith Red Fish
Smith Blue Fish
Jones Twas brillig and
Jones the slithy toves did
Jones gyre and gimble in the wabe
** Sort the data;
proc sort data=allcom;
by l_name origord;
** Transpose the data;
proc transpose data=allcom out=tr_out;
** Make the NewComment variable;
data newcom (keep=l_name newcomment);
length col1 col2 col3 col4 col5 $30 newcomment $150;
Dorfman and Whitlock are names of experts who in discussion together came up with an approach that moves the SET statement away from the top of a data step into a loop. The approach is acquiring the title DoW loop.
Here it is most helpful[pre] data reduced( keep= L_name comment compress=yes ) ;
length comment $2000 ; * surely enough, but can be wider ;
do until( last.L_name ) ;
set full_data_set( rename=( comment= oneComment )) ;
by L_name ;
comment= trimn( comment ) !! oneComment ;
run ; [/pre]The merit of DoW looping is brief code using the nature of the data step to help solve the problem.
See Paul Dorfman's 2009 paper on the topic at http://support.sas.com/resources/papers/proceedings09/038-2009.pdf
I'm sure understanding and mastering the technique is an important stage in learning to program in a SAS System environment.