Sample 25493: Updating a bank Master file
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample is from the SAS Sample Library. For additional information refer to SAS Help and Online Documentation.
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: UPDATE2 */
/* TITLE: Updating a Bank Master File */
/* PRODUCT: SAS */
/* SYSTEM: PC DOS */
/* KEYS: DATMAN DATASTEP UPDATE BY SUM KEEP */
/* PROCS: PRINT */
/* DATA: */
/* */
/* SUPPORT: UPDATE: */
/* REF: */
/* MISC: */
/* */
/****************************************************************/
DATA MASTER;
INPUT ACCT BALANCE;
CARDS;
3152617 1203.35
3355912 342.13
3999249 9823.45
4102477 200.34
4999999 100
;
PROC PRINT;
TITLE2 'MASTER FILE';
RUN;
DATA TRANSACT;
INPUT ACCT TYPE $ AMMOUNT;
CARDS;
3355912 DEBIT 23.12
4102477 CREDIT 110
4102477 DEBIT 1.23
4999999 DELETE .
5023541 CREDIT 100
;
PROC PRINT;
TITLE2 'TRANSACTION FILE';
RUN;
DATA MASTER2;
UPDATE MASTER TRANSACT;
BY ACCT;
IF TYPE='CREDIT' THEN BALANCE+AMMOUNT;
ELSE IF TYPE='DEBIT' THEN BALANCE+-AMMOUNT;
ELSE IF TYPE='DELETE' THEN DO;
PUT 'DELETED ' ACCT= BALANCE=;
DELETE;
END;
KEEP ACCT BALANCE;
RUN;
PROC PRINT;
TITLE2 'NEW MASTER FILE';
RUN;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
MASTER FILE
Obs ACCT BALANCE
1 3152617 1203.35
2 3355912 342.13
3 3999249 9823.45
4 4102477 200.34
5 4999999 100.00
TRANSACTION FILE
Obs ACCT TYPE AMMOUNT
1 3355912 DEBIT 23.12
2 4102477 CREDIT 110.00
3 4102477 DEBIT 1.23
4 4999999 DELETE .
5 5023541 CREDIT 100.00
NEW MASTER FILE
Obs ACCT BALANCE
1 3152617 1203.35
2 3355912 319.01
3 3999249 9823.45
4 4102477 309.11
5 5023541 100.00
This example demonstrates how to update a bank Master file.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Statements ==> File-handling ==> UPDATE
|
| Date Modified: | 2005-12-08 11:34:46 |
| Date Created: | 2005-05-23 13:57:31 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |