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 -

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
  • 4 replies
  • 690 views
  • 0 likes
  • 3 in conversation