This week's SAS tip is from Ron Cody and his new book Cody's Collection of Popular SAS Programming Tasks and How to Tackle Them. If you're a SAS user and haven't explored Ron's work, you're missing out! Visit Ron's author page to view his extensive list of SAS books, user reviews, free chapters, and more.
The following excerpt is from SAS Press author Ron Cody and his book "Cody's Collection of Popular SAS Programming Tasks and How to Tackle Them". Copyright © 2012, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED. (please note that results may vary depending on your version of SAS software)
Using a MODIFY statement to update a master file from a transaction file
If you prefer to update your original SAS data set with data from a transaction file, you can use a MODIFY statement. Unlike UPDATE, this technique does not create a new data set but modifies the original data set.
Although you do not have to sort your master file and transaction file when using a MODIFY statement followed by a BY statement, doing so will improve efficiency.
The following short program shows how you can update a master file from data in a transaction file using MODIFY:
After you run this program, the SAS data set Hardware will be identical to the Hardware_June2012 data set created in the previous task.
View additional SAS tips from Ron Cody's books that have been featured on this blog: Computing some useful constants; Using informats to filter invalid values; A short-cut for requesting multiple tables and Creating a bar chart using PROC SGPLOT.