BookmarkSubscribeRSS Feed
PriyaSaha
Calcite | Level 5

Can any body explain me how merge ,set and update are differently work ?

Thanks in advance ,

Priya

5 REPLIES 5
jadhavsada1_gmail_com
Fluorite | Level 6

**merge**

  -> merge usually joins datasets with different variable.

     output datasets contain all the variables from all datasets.

      up to 100 datasets can merge i one step.

      observations are match merge with BY statement

   ex= data onetoonemerging;

             merge one two;

            run;

   ex2= data matchmerge;

           merge one two ;

           by id;

           run;

  **SET**

-> combining two or more sas datasets into a single sas datasets one after another using SET stmt that is also called concatation.

     if original datasets contai diff. data types for variables concatenation wont happen.

     ex= data sada;

             set one two;

            run;

in SET stmt we can also use a dataset table option like obs,firstobs,keep,rename and drop.

**Update**

-> if we want to update a dataset if the record exist in dataset then it update otherwise insert it .

  ex= data one ;

        update one two;

        by id ;

        run;

Tom
Super User Tom
Super User

Read the on-line docs for more complete descriptions.

MERGE is for combining data side-by-side.

SET is for combining data top-to-bottom.

UPDATE is for applying transactions to a master dataset.

Howles
Quartz | Level 8

also MODIFY

arpi
Fluorite | Level 6

 

 

Merge and update is almost same but they differ with certian scenarios:

 

With MERGE, you’re able to combine update, delete, and insert command into one statement.   This is because the MERGE statement uses a WHEN clause to determine the course of action to take on the match.

 

With a MERGE, you can take different actions based on the rows matching or not matching the target or source.  With the updated, you’re only updating rows that match.

 

with merge you can merge two or more datafiles together and there are variations with merge too, left-merge, right-merge... etc

 

I hope this helps!!!

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!

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.

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
  • 5 replies
  • 13968 views
  • 5 likes
  • 6 in conversation