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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.