How can I concatenate multiple columns in PROC SQL statement using ALTER? And I don't want to use SELECT statement since in that case, I will have to mention all the columns and the table on which I am working has more than 100 columns whereas in the ALTER statement you just need to mention the column you are adding.
You will get ALL variables, unless you drop them:
data have;
input x $ y $;
datalines;
a b
;
data want;
set have;
z = cats(x,y);
run;
proc print data=want noobs;
run;
Result:
x y z a b ab
The ALTER TABLE statement can be used to just add a column, but it will initialize it with missing values. You need to also use an UPDATE that sets the values as needed.
I would rather use a DATA step to do this (add a column and use concatenation of values to populate it).
You will get ALL variables, unless you drop them:
data have;
input x $ y $;
datalines;
a b
;
data want;
set have;
z = cats(x,y);
run;
proc print data=want noobs;
run;
Result:
x y z a b ab
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.