Hi all, I'm struggling with carrying data from one row to the next using a method that I'm pretty sure has worked in the past. I simply want to carry the 'name' from one row to the next, within each table subset, and end up with a last.table record which has all of the names in that table concatenated into one string. I also want to make use of the 'retain' function.
This is my current data:
name
table
rowcat
Riley
t1
Henderson
t1
MacDonald
t1
Cook
t1
DuPage
t2
Samoa
t2
This is what I want:
name
table
rowcat
Riley
t1
Riley,
Henderson
t1
Riley, Henderson,
MacDonald
t1
Riley, Henderson, MacDonald,
Cook
t1
Riley, Henderson, MacDonald, Cook,
DuPage
t2
DuPage,
Samoa
t2
DuPage, Samoa,
Can anyone help me understand why this code isn't working?
data have;
length name $ 12 table $ 2 rowcat $ 200;
input name $ table $;
datalines;
Riley t1
Henderson t1
MacDonald t1
Cook t1
DuPage t2
Samoa t2
;
run;
proc sort data=have; by table; run;
data want;
set have;
by table;
if first.table then do;
rowcat = ' ';
end;
rowcat = strip(strip(name)||", "||strip(rowcat));
retain rowcat;
run;
Thanks!!
... View more