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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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