data t1;
input letter1 $;
cards;
a1
b1
c1
;;;;
data t2;
input letter2 $;
cards;
a2
b2
c2
;;;;
proc sql;
create table want as
select t1.letter1, t2.letter2, catt(t1.letter1, t2.letter2) as comb
from t1, t2;
quit;
That's the quickest coding way.
How do you get 12 as?
What's the logic here, all combinations of a/b/c?
@meckarthik wrote:
Hi , I got two columns
1 aa
2 bb
3 cc
How to code in sas for combination
I want output to look like
1 aa
1 BB
2 aa
12 as
13 bb
123 aa
Etc
All possible combinations
Thanks
data t1;
input letter1 $;
cards;
a1
b1
c1
;;;;
data t2;
input letter2 $;
cards;
a2
b2
c2
;;;;
proc sql;
create table want as
select t1.letter1, t2.letter2, catt(t1.letter1, t2.letter2) as comb
from t1, t2;
quit;
That's the quickest coding way.
Hi, expanded the query for 3 tables and it worked perfectly well. Just waiting for the final sign off!!!
& Thank you so much!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for 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.