Wednesday 23 November 2016

SAS Update Statement - Combining Datasets

Update Statement : 
Many applications in real world require to update master datasets with transaction data set; 
For example when we need to update the original mailing list with changed addresses or one may need update list of master inventories.

This is very simple using SAS UPDATE statement. With update statement SAS reads observation from transaction dataset and finds out corresponding record in master dataset using key specified in by group variables. Then it updates master dataset with new values in transaction dataset

Important
1. Master datasets wont get updated if corresponding columns in transaction dataset are missing;
it gets update with non missing values only.
2. If there is new record in transaction dataset which don’t find corresponding records in master dataset in that case new record is added into the master dataset.
3.Master datset should not have duplicates with specified key group. If SAS finds duplicates then we get warning in the log and the changes get applied only to 1st obs in that by group.
4.Both datasets need to be sorted already. 

No comments:

Post a Comment