BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RoddyJ
Obsidian | Level 7

I have two single column data sets with unique variables. I'd like to merge them to create a 2 column data set with an observation for every pair of variables from the the two original data sets. See example below.

 

I have the below two data sets with 1 column each:

cat1
a
b
c
d
e

 

cat2
1
2
3
4

 

I want the below data set:

 

cat1 cat2
a 1
a 2
a 3
a 4
b 1
b 2
b 3
b 4
c 1
c 2
etc... etc...
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

data one;
input cat1 $;
cards;
a
b
c
d
e
;

data two;
 input cat2 ;
 cards;
1
2
3
4
;

proc sql;
 create table want as
 select cat1, cat2
 from one , two
 order by cat1,cat2;
quit;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

data one;
input cat1 $;
cards;
a
b
c
d
e
;

data two;
 input cat2 ;
 cards;
1
2
3
4
;

proc sql;
 create table want as
 select cat1, cat2
 from one , two
 order by cat1,cat2;
quit;
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1269 views
  • 2 likes
  • 3 in conversation