of the Month
There are a number of ways which a master dataset can be updated from a transaction dataset, but here is an olde and a goodie which I still use occasionally.
Here is some data in my MASTER dataset:
Stadium Unsold_Seats Last_Update North Side 20,000 31DEC2012 South Side 18,000 31DEC2012 East Side 21,000 31DEC2012 West Side 16,000 31DEC2012 Central 14,000 31DEC2012
For our example, on January 1st East Side and Central locations were open and at the end of the day the tickets unsold were:
Stadium Unsold_Seats East Side 19,000 Central 11,000
Now lets update using the following code:
proc sort data=MASTER; by stadium last_update; data TRANSACTION; set TRANSACTION; last_update='01JAN2013'd; proc sort data=TRANSACTION; by stadium last_update; data MASTER; merge MASTER TRANSACTION; by stadium last_update; if last.stadium; run;
In the TRANSACTION dataset we have put the date of the transaction in the file, then sorted both datasets, then merged by the STADIUM and LAST_UPDATE variables, taking the last STADIUM value into the MASTER dataset.
There are a number of variations of this that can be useful, but this is the basic update.
Have a safe and happy January.
Updated January 01, 2013