You can update a
SAS data file with SYSTEM 2000 data that is described by a
view descriptor just as you can update a SAS data file by using another data file, that is, by using
an UPDATE statement in a DATA step. In this section, the term
transaction
data refers to the new data that is added to the original
file. Because the
SAS/ACCESS interface to SYSTEM 2000 uses the SAS 6 compatibility
engine, the transaction data is from a SAS 6 source. However, the original file can be a
SAS 6 or later data file.
Suppose you have the
SAS 6 data file V6.Birthdy
that contains the names and birthdays of the employees in Marketing.
The file is out-of-date, and you want to update it with data described
by Vlib.EmpBd.
To perform the update, submit the following program:
proc sort data=v6.birthdy;
by lastname;
run;
data mydata.newbday;
update v6.birthdy vlib.empbd;
by lastname firstnme;
run;
In this example, when the UPDATE statement references the view descriptor Vlib.EmpBd
and uses a BY statement in the DATA step, the BY statement causes the
interface view engine to automatically generate a SYSTEM 2000
ordering-clause for the
variable LASTNAME. The ordering-clause causes the SYSTEM 2000 data to be presented to SAS
already sorted so that the SYSTEM 2000 DATA can be used to update the data file MyData.NewBday.
The data file V6.Birthdy had to be sorted before the update because the UPDATE statement
needs the data sorted by the BY variable.
The following three
outputs show the results of PROC PRINT on the original data file,
the transaction data, and the updated data file.
Data File to Be Updated, V6.Birthdy
V6.BIRTHDY Data File 1
OBS LASTNAME FIRSTNME BIRTHDAY
1 JONES FRANK 22MAY53
2 MCVADE CURTIS 25DEC54
3 SMITH VIRGINIA 14NOV49
4 TURNER BECKY 26APR50
Data Described by the View Descriptor Vlib.EmpBd
Data Described by VLIB.EMPBD 1
OBS LASTNAME FIRSTNME BIRTHDAY
1 AMEER DAVID 10OCT51
2 BROOKS RUBEN R. 25FEB52
3 BROWN VIRGINA P. 24MAY46
4 CHAN TAI 04JUL46
5 GARRETT OLAN M. 23JAN35
6 GIBSON GEORGE J. 23APR46
7 GOODSON ALAN F. 21JUN50
8 JUAREZ ARMANDO 28MAY47
9 LITTLEJOHN FANNIE 17MAY54
10 RICHARDSON TRAVIS Z. 30NOV37
11 RODRIGUEZ ROMUALDO R 09FEB29
12 SCHOLL MADISON A. 19MAR45
13 SHROPSHIRE LELAND G. 04SEP49
14 SMITH JERRY LEE 13SEP42
15 VAN HOTTEN GWENDOLYN 13SEP42
16 WAGGONNER MERRILEE D 27APR36
17 WILLIAMSON JANICE L. 19MAY52
Updated Data File, MyData.NewBday
MYDATA.NEWBDAY Data File 1
OBS LASTNAME FIRSTNME BIRTHDAY
1 AMEER DAVID 10OCT51
2 BROOKS RUBEN R. 25FEB52
3 BROWN VIRGINA P. 24MAY46
4 CHAN TAI 04JUL46
5 GARRETT OLAN M. 23JAN35
6 GIBSON GEORGE J. 23APR46
7 GOODSON ALAN F. 21JUN50
8 JONES FRANK 22MAY53
9 JUAREZ ARMANDO 28MAY47
10 LITTLEJOHN FANNIE 17MAY54
11 MCVADE CURTIS 25DEC54
12 RICHARDSON TRAVIS Z. 30NOV37
13 RODRIGUEZ ROMUALDO R 09FEB29
14 SCHOLL MADISON A. 19MAR45
15 SHROPSHIRE LELAND G. 04SEP49
16 SMITH JERRY LEE 13SEP42
17 SMITH VIRGINIA 14NOV49
18 TURNER BECKY 26APR50
19 VAN HOTTEN GWENDOLYN 13SEP42
20 WAGGONNER MERRILEE D 27APR36
21 WILLIAMSON JANICE L. 19MAY52