data have;
infile cards dlm=',';
informat product_Id $8. type $8. Description $20.;
input Product_ID Type Description;
cards;
12, A, Made of wood
12, B, Made of wood
25, C, Made of steel
15, D, Made of iron
12, F, Made of wood 28, G, Made of paper
; data want;
set have;
by product_id description NOTSORTED; /* <-------- */
length types $20.;
retain types;
if first.description then call missing(types);
types = catx(", ", types, type);
if last.description then do;
description = catt(description, " (", types, ")");
output;
end;
keep product_id description;
run; I'm expecting output to be like shown below, please help on what am i missing.Please note that the type is added to the description within paranthesis only when description is the same between the products I'm expecting output to be like shown below My output should look like below Product_ID description
12 Made of paper(G)
12 Made of Wood(A,B,F) 15 Made of iron ( D)
25 Made of steel (C)
... View more