In the following example, two managers have kept separate employee telephone lists.
The Marketing manager kept records in the SYSTEM 2000
database Employee, which is described by the view descriptor Vlib.EmpPhon. The Corporation
manager kept records for the executive telephone list
in the SAS 6
SAS data file MyData.CorPhon. The two sources must be combined to create a telephone list of employees
in both departments.
The data that is described by the view descriptor Vlib.EmpPhon and the data in the
SAS data file MyData.CorPhon are displayed in the two outputs following the example.
proc print data=vlib.empphon;
title 'Marketing Phone List';
run;
proc print data=mydata.corphon;
title 'Corporation Phone List';
run;
Data Described by Vlib.EmpPhon
Marketing Phone List 1
OBS LASTNAME FIRSTNME PHONE
1 AMEER DAVID 545 XT495
2 BROOKS RUBEN R. 581 XT347
3 BROWN VIRGINA P. 218 XT258
4 CHAN TAI 292 XT331
5 GARRETT OLAN M. 212 XT208
6 GIBSON GEORGE J. 327 XT703
7 GOODSON ALAN F. 323 XT512
8 JUAREZ ARMANDO 506 XT987
9 LITTLEJOHN FANNIE 219 XT653
10 RICHARDSON TRAVIS Z. 243 XT325
11 RODRIGUEZ ROMUALDO R 243 XT874
12 SCHOLL MADISON A. 318 XT419
13 SHROPSHIRE LELAND G. 327 XT616
14 SMITH JERRY LEE 327 XT169
15 VAN HOTTEN GWENDOLYN 212 XT311
16 WAGGONNER MERRILEE D 244 XT914
17 WILLIAMSON JANICE L. 218 XT802
Data in MyData.CorPhon
Corporation Phone List 1
OBS LASTNAME FIRSTNME PHONE
1 BOWMAN HUGH E. 109 XT901
2 FAULKNER CARRIE ANN 132 XT417
3 GARRETT OLAN M. 212 XT208
4 KNAPP PATRICE R. 222 XT 12
5 KNIGHT ALTHEA 213 XT218
6 MILLSAP JOEL B. 131 XT224
7 MUELLER PATSY 223 XT822
8 NATHANIEL DARRYL 118 XT544
9 SALAZAR YOLANDA 111 XT169
10 WATERHOUSE CLIFTON P. 101 XT109
To combine the data described by these two sources, use PROC APPEND, as shown in the
following program. The following output displays the data in the updated data file
MyData.CorPhon. Notice that the combined data is sorted by last name. Also, because
PROC PRINT was used to display the data, the
variable names are used (for example, FIRSTNME), not the variable labels, which are the item
names (for example, FORENAME).
proc append base=mydata.corphon data=vlib.empphon;
run;
proc sort data=mydata.corphon;
by lastname;
proc print data=mydata.corphon;
title 'Corporation and Marketing Phone List';
run;
Appended Data
Corporation and Marketing Phone List 1
OBS LASTNAME FIRSTNME PHONE
1 AMEER DAVID 545 XT495
2 BOWMAN HUGH E. 109 XT901
3 BROOKS RUBEN R. 581 XT347
4 BROWN VIRGINA P. 218 XT258
5 CHAN TAI 292 XT331
6 FAULKNER CARRIE ANN 132 XT417
7 GARRETT OLAN M. 212 XT208
8 GARRETT OLAN M. 212 XT208
9 GIBSON GEORGE J. 327 XT703
10 GOODSON ALAN F. 323 XT512
11 JUAREZ ARMANDO 506 XT987
12 KNAPP PATRICE R. 222 XT 12
13 KNIGHT ALTHEA 213 XT218
14 LITTLEJOHN FANNIE 219 XT653
15 MILLSAP JOEL B. 131 XT224
16 MUELLER PATSY 223 XT822
17 NATHANIEL DARRYL 118 XT544
18 RICHARDSON TRAVIS Z. 243 XT325
19 RODRIGUEZ ROMUALDO R 243 XT874
20 SALAZAR YOLANDA 111 XT169
21 SCHOLL MADISON A. 318 XT419
22 SHROPSHIRE LELAND G. 327 XT616
23 SMITH JERRY LEE 327 XT169
24 VANHOTTEN GWENDOLYN 212 XT311
25 WAGGONNER MERRILEE D 244 XT914
26 WATERHOUSE CLIFTON P. 101 XT109
27 WILLIAMSON JANICE L. 218 XT802
PROC APPEND also accepts a WHERE= data set option or a WHERE statement to subset
the observations from the DATA= data set that
is added to the BASE= data set, as shown in the following program. (It is assumed
that the data file MyData.CorPhon is in its original state before executing PROC APPEND
in the preceding program.) The following output displays the results.
proc append base=mydata.corphon
data=vlib.empphon(where=(lastname='AMEER'));
run;
proc print data=mydata.corphon;
title2 'Appended Data with a WHERE= Data Set Option';
run;
Appended Data with a WHERE= Data Set Option
Appended Data with a WHERE= Data Set Option 1
OBS LASTNAME FIRSTNME PHONE
1 BOWMAN HUGH E. 109 XT901
2 FAULKNER CARRIE ANN 132 XT417
3 GARRETT OLAN M. 212 XT208
4 KNAPP PATRICE R. 222 XT 12
5 KNIGHT ALTHEA 213 XT218
6 MILLSAP JOEL B. 131 XT224
7 MUELLER PATSY 223 XT822
8 NATHANIEL DARRYL 118 XT544
9 SALAZAR YOLANDA 111 XT169
10 WATERHOUSE CLIFTON P. 101 XT109
11 AMEER DAVID 545 XT495