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

Hi,

 

Pls explain me the second point,

 

[1]Duplicate BY Values

Duplicates in the master and transaction data sets affect processing.

  • If duplicates exist in the master data set, only the first occurrence is updated because the generated WHERE statement always finds the first occurrence in the master.

  • If duplicates exist in the transaction data set, the duplicates are applied one on top of another unless you write an accumulation statement to add all of them to the master observation. Without the accumulation statement, the values in the duplicates overwrite each other so that only the value in the last transaction is the result in the master observation

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Maxim 4 comes into play. Just Try It:

data master;
input id value;
cards;
1 3
1 2
2 2
3 4
4 2
4 1
;
run;

data trans;
input id value;
cards;
1 6
2 4
3 5
3 6
4 7
4 8
;
run;

data master;
modify master trans;
by id;
run;

proc print data=master noobs;
run;

This is the result:

id    value

 1      6  
 1      2  
 2      4  
 3      6  
 4      8  
 4      1  

With ID 1, there's a duplicate in the master; only the first observation is updated, the second is unaffected.

With ID 3, there's a duplicate in the trans; only the last of that takes effect in the master.

With ID 4, both trans are worked into the first master, with the second taking effect; the second obs in the master stays unaffected.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

Maxim 4 comes into play. Just Try It:

data master;
input id value;
cards;
1 3
1 2
2 2
3 4
4 2
4 1
;
run;

data trans;
input id value;
cards;
1 6
2 4
3 5
3 6
4 7
4 8
;
run;

data master;
modify master trans;
by id;
run;

proc print data=master noobs;
run;

This is the result:

id    value

 1      6  
 1      2  
 2      4  
 3      6  
 4      8  
 4      1  

With ID 1, there's a duplicate in the master; only the first observation is updated, the second is unaffected.

With ID 3, there's a duplicate in the trans; only the last of that takes effect in the master.

With ID 4, both trans are worked into the first master, with the second taking effect; the second obs in the master stays unaffected.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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