Help using Base SAS procedures

removing trailing commas from concatenation

Reply
Occasional Contributor
Posts: 12

removing trailing commas from concatenation

I am working on a report that requires concatenating multiple records into one field. I first transposed my table and tried to concatenate everything into one column. The problem I encountered is that some observations have only one record of interest while others have as many as eight so when trying to separate each record in the concatenated column I get trailing commas for any cases that have less than eight records. How can I get rid of the trailing commas? Thanks.
Respected Advisor
Posts: 3,799

Re: removing trailing commas from concatenation

CATX should help.

[pre]
proc sort data=sashelp.class out=_data_;
by age;
run;
proc transpose;
by age;
var weight;
run;
proc print;
run;
options missing=' ';
data;
set;
length w $64;
w = catX(', ',of colSmiley Happy;
drop col:;
run;
proc print;
run;
[/pre]
Regular Contributor
Posts: 241

Re: removing trailing commas from concatenation

Use CATX function.

data _null_;
   a = ""; b = "b";
   ab = catx(",",a,b);
   put (_all_) (=);
run;
/* on log
   a=  b=b ab=b
*/

Occasional Contributor
Posts: 12

Re: removing trailing commas from concatenation

Posted in reply to chang_y_chung_hotmail_com
This worked. Thanks!
Ask a Question
Discussion stats
  • 3 replies
  • 663 views
  • 0 likes
  • 3 in conversation