🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-09-2019 11:18 AM
(1908 views)
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
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
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
13 REPLIES 13
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hey, sorry typo error. Yes I want all combinations of a/b/c . That should also include abc1, bc1, 123abc etc. Let me know if it doesn't make sense
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What do you start out with exactly then?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I start with
Single match
1 a
2 a
Etc
Goes maximum 3 from column a and 3 from column b
Something like 3*3 matrices
123 ABC
123 acb
231 CBA
Whether it make sense
Thanks for helping on this
Single match
1 a
2 a
Etc
Goes maximum 3 from column a and 3 from column b
Something like 3*3 matrices
123 ABC
123 acb
231 CBA
Whether it make sense
Thanks for helping on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You've gone from 2 matches, aa, ab, ac among three options to three way matches which is different.....so which is it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So sorry it's two columns only
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
2 way match will do, thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, expanded the query for 3 tables and it worked perfectly well. Just waiting for the final sign off!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
& Thank you so much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
2 by 2 matrix only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't know what that means.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks I will work on this and feedback.