BookmarkSubscribeRSS Feed
mrob
Calcite | Level 5

Hi,

 

i have two data sets and i want final data set to have all cust_1 corresponding values to cust;

please see below inputs and outputs.

 

data 1;        

cust

123

456

789

012

 

 

data2;

cust_1

345

678

901

 

desired output ;

cust cust_1

123  345

456  345

789  345

012  345

123  678

456  678

789  678

012  678

123  901

456  901

789  901

012  901

 

thanks

 

 

4 REPLIES 4
Astounding
PROC Star

For many-to-many, all combinations matching, SQL is simplest:

 

proc sql;

create table want as select * from data1, data2;

quit;

mrob
Calcite | Level 5
Hi thanks for prompt response.
But I have already tried the code you mentioned and does not gives me the
require output. Can you please check desired output and advise?

Thanks
Rob
##- Please type your reply above this line. Simple formatting, no
attachments. -##
Astounding
PROC Star

I won't be able to actually run any tests until Monday.  But you can help by explaining what you mean when you say it doesn't give you the desired output.

 

Did you get an error message?

 

DId you get output that was different than what you wanted?

 

In either case, show any helpful information (starting with the log from your test).

Oligolas
Barite | Level 11

Hi,

 

@Astounding's code is correct.

 

data one;        
input cust $;
cards;
123
456
789
012
;
run;
 
 
data two;
input cust_1 $;
cards;
345
678
901
;
run;
 
proc sql;
   create table want as select * from one, two;
quit;
________________________

- Cheers -

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1240 views
  • 0 likes
  • 3 in conversation