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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: