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

Hi guys,

 

I have 2 datasets with one common value, let's call that value 'source'. 

 

set 1

 

source    file

1              A12

1              Ddd55      

56            C566

57            D684

 

so one source can have multiple files (source is not a unique column), l

let's assume the max files per source is 3. 

each file is unique.

 

set 2

 

source   code

1              A

1              B      

1              C

56            D

56            E

56            F

57            G

57            H

57            I

 

so in this dataset there are 3 codes for each source. all these codes are unique. 

 

I need to assign a code from dataset 2 to each source in dataset 1, 

keeping the unique character (so 1 code per file). 

 

so the result would have to be something like:

 

source    file             code 

1              A12          A 

1              Ddd55      B

56            C566        D

57            D684        G

 

 

I'm breaking my head because I believe the solution will probably be very simple???

1 ACCEPTED SOLUTION

Accepted Solutions
ghosh
Barite | Level 11
data want;
  merge set1(in=a) set2;
  by source;
  if a;
run;

View solution in original post

1 REPLY 1
ghosh
Barite | Level 11
data want;
  merge set1(in=a) set2;
  by source;
  if a;
run;

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 619 views
  • 0 likes
  • 2 in conversation