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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.