I prefer (IMHO) cgdev's solution, you can fix the problem with the last item as described below:
assign
xyz = replace(xyz,entry(<what ever entry in list>,xyz),'':U) /* remove entry */
xyz = replace(xyz,',,':U,',':U) /* remove doubled commas */
xyz = trim(xyz,',':U)...