Hello Programmers,
I have a simple ask to concatenate 5 columns with a comma separator with a condition.
Dataset = INPUTA
Columns = C1 through C5
Expected Outcome
Need a column that would concatenate all 5 columns with comma separator in sequence when there is a value and ignore if the column is blank.
State | C1 | C2 | C3 | C4 | C5 | CustomColumn |
CA | X | A | X,A | |||
WI | X | R | B | X,R,B | ||
MI | Y | T | X | I | Y,T,X,I |
data want;
set have;
CustomColum=catx(',',of c1-c5);
run;
CustomColum=catx(',',of c1-c5);
Thanks Novin,
Could you help with the full code here ?
Proc or Data ?
data want;
set have;
CustomColum=catx(',',of c1-c5);
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.