I have a table that has two numeric values called year
and month
. I would like to create a new table that has one value called ym
which is just the concatenation of year
and month
. Here is an example:
proc sql;
create table test as
select CONCAT(year, month) as ym from tbl;
run;
What is the CONCAT
function that goes there?
CAT, CATS, CATT, CATX all perform concatenation, as long as you're on 9.1.3 or later (and CATQ on 9.2 or later); CAT does basic concatenation, CATS concatenates and strips spaces, CATT trims, and CATX concatenates with a delimiter.
Typically CATS is the correct function to use for numbers, since by default numbers are put into a format with spaces (BEST12., so "3 " is 3).
proc sql;
create table test as
select CATS(year, month) as ym from tbl;
run;