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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.