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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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