06-18-2015 04:40 PM
I'm wondering what is the best way to update a master dataset from several transactional dataset.
The situation is , master contains 1728 records, and i have 10 different transactional dataset to update this master dataset ( one for each month), the goal is to see after 10 months, how these 1728 records would look like. so if the transac data contains more records than master, don't add them. if contains less records and non-matching records, only update the matching ones and leave the unmatched stay the same. I've tried update statement together with merge statement, part of my code is as follows:
if a and b ;
so here result_start is my master data, for each iteration, i want to use result&num to update result_start, however, the update statement would add new records onto master data, so i have to do a merge step to get rid of the unwanted records and hopefully keep the master data updated.
Could anyone tell me if i was doing anything wrong here ,and if there is a better way to do this.
06-18-2015 04:54 PM
Untested, but I imagine you could do this in one step and eliminate the MERGE:
update result_start (in=in_master)
if in_master=0 then delete;
06-18-2015 09:02 PM
You do know how the UPDATE statement works right? How it handles missing values and repeats of BY variables is very different than the MERGE statement.
The UPDATE statement is for applying transactions. It requires exactly two datasets. But you could make a view that combines all of your transactions into one and then apply them.
data transactions/ view=transactions ;
set result1 - result10 ;
data want ;
update master transactions;