In earlier releases of SAS,
the APPEND procedure operated only on SAS data files. You can append
data that is described by
SAS/ACCESS view descriptors and PROC SQL
views to SAS data files and vice versa. You can also append data that
is described by view descriptors to each other.
In the following example,
two personnel managers have kept separate employee records. One manager
has kept records in a NATURAL DDM named EMPLOYEE, which is described
by the view descriptor VLIB.ADAEMPS. The other manager has kept records
in a SAS data file that is named MYDATA.SASEMPS. Due to a corporate
reorganization, the two sources of data must be combined so that all
employee data is stored in the EMPLOYEE DDM. The APPEND procedure
can do this.
The data that is described
by the view descriptor VLIB.ADAEMPS and the data that is in the SAS
data file MYDATA.SASEMPS are printed with the following statements
and displayed in the following two outputs:
options linesize=80;
proc print data=vlib.adaemps;
title 'Data Described by VLIB.ADAEMPS';
run;
proc print data=mydata.sasemps;
format birthdat date7.;
title 'Data in MYDATA.SASEMPS Data File';
run;
Data That Is Described by VLIB.ADAEMPS
Data Described by VLIB.ADAEMPS
OBS EMPID BIRTHDAT LASTNAME FIRSTNAM MIDDLENA
1 119012 05JAN46 WOLF-PROVENZA G. ANDREA
2 120591 12FEB46 HAMMERSTEIN S. RACHAEL
3 123456 . VARGAS PAUL JESUS
4 127845 25DEC43 MEDER VLADIMIR JORAN
5 129540 31JUL60 CHOULAI CLARA JANE
6 135673 21MAR61 HEMESLY STEPHANIE J.
7 212916 29MAY28 WACHBERGER MARIE-LOUISE TERESA
8 216382 24JUL63 PURINTON PRUDENCE VALENTINE
9 234967 21DEC67 SMITH GILBERT IRVINE
10 237642 13MAR54 BATTERSBY R. STEPHEN
11 239185 28AUG59 DOS REMEDIOS LEONARD WESLEY
12 254896 06APR49 TAYLOR-HUNYADI ITO MISHIMA
13 321783 03JUN35 GONZALES GUILLERMO RICARDO
14 328140 02JUN51 MEDINA-SIDONIA MARGARET ROSE
15 346917 15MAR50 SHIEKELESLAM SHALA Y.
16 356134 25OCT60 DUNNETT CHRISTINE MARIE
17 423286 31OCT64 MIFUNE YUKIO TOSHIRO
18 456910 24SEP53 ARDIS RICHARD BINGHAM
19 456921 12MAY62 KRAUSE KARL-HEINZ G.
20 457232 15OCT63 LOVELL WILLIAM SINCLAIR
21 459287 05JAN34 RODRIGUES JUAN M.
22 677890 24APR65 NISHIMATSU-LYNCH CAROL ANNE
Data in MYDATA.SASEMPS
Data in MYDATA.SASEMPS Data File
OBS EMPID BIRTHDAT LASTNAME FIRSTNAM MIDDLENA
1 245962 30AUG64 BEDORTHA KATHY MARTHA
2 765432 01MAR59 POWELL FRANK X.
3 219223 13JUN47 HANSINGER BENJAMIN HAROLD
4 326745 21FEB52 RAWN BEATRICE MAY
The following statements
use the APPEND procedure to combine the data from these two sources:
proc append base=vlib.adaemps
data=mydata.sasemps;
run;
proc print data=vlib.adaemps;
title 'Appended Data';
run;
The following output
displays the appended data that is described by the view descriptor
VLIB.ADAEMPS. Notice that the data in MYDATA.SASEMPS follows the
data that is described by VLIB.ADAEMPS.
Results of Appending Data with the APPEND Procedure
Appended Data
OBS EMPID BIRTHDAT LASTNAME FIRSTNAM MIDDLENA
1 119012 05JAN46 WOLF-PROVENZA G. ANDREA
2 120591 12FEB46 HAMMERSTEIN S. RACHAEL
3 123456 . VARGAS PAUL JESUS
4 127845 25DEC43 MEDER VLADIMIR JORAN
5 129540 31JUL60 CHOULAI CLARA JANE
6 135673 21MAR61 HEMESLY STEPHANIE J.
7 212916 29MAY28 WACHBERGER MARIE-LOUISE TERESA
8 216382 24JUL63 PURINTON PRUDENCE VALENTINE
9 234967 21DEC67 SMITH GILBERT IRVINE
10 237642 13MAR54 BATTERSBY R. STEPHEN
11 239185 28AUG59 DOS REMEDIOS LEONARD WESLEY
12 254896 06APR49 TAYLOR-HUNYADI ITO MISHIMA
13 321783 03JUN35 GONZALES GUILLERMO RICARDO
14 328140 02JUN51 MEDINA-SIDONIA MARGARET ROSE
15 346917 15MAR50 SHIEKELESLAM SHALA Y.
16 356134 25OCT60 DUNNETT CHRISTINE MARIE
17 423286 31OCT64 MIFUNE YUKIO TOSHIRO
18 456910 24SEP53 ARDIS RICHARD BINGHAM
19 456921 12MAY62 KRAUSE KARL-HEINZ G.
20 457232 15OCT63 LOVELL WILLIAM SINCLAIR
21 459287 05JAN34 RODRIGUES JUAN M.
22 677890 24APR65 NISHIMATSU-LYNCH CAROL ANNE
23 245962 30AUG64 BEDORTHA KATHY MARTHA
24 765432 01MAR59 POWELL FRANK X.
25 219223 13JUN47 HANSINGER BENJAMIN HAROLD
26 326745 21FEB52 RAWN BEATRICE MAY
The APPEND procedure
also accepts a WHERE= data set option or a SAS WHERE statement to
retrieve a subset of the data. In the following example, a subset
of the observations from MYDATA.SASEMPS is added to VLIB. ADAEMPS.
proc append base=vlib.adaemps
data=mydata.sasemps
(where=(birthdat>='01JAN60'd));
run;
proc print data=vlib.adaemps;
title 'Appended Data with a WHERE= Data Set
Option';
run;
The results are displayed
in the following output.
Results of Appending Data with a WHERE= Data Set Option
Appended Data with a WHERE= Data Set Option
OBS EMPID BIRTHDAT LASTNAME FIRSTNAM MIDDLENA
1 119012 05JAN46 WOLF-PROVENZA G. ANDREA
2 120591 12FEB46 HAMMERSTEIN S. RACHAEL
3 123456 . VARGAS PAUL JESUS
4 127845 25DEC43 MEDER VLADIMIR JORAN
5 129540 31JUL60 CHOULAI CLARA JANE
6 135673 21MAR61 HEMESLY STEPHANIE J.
7 212916 29MAY28 WACHBERGER MARIE-LOUISE TERESA
8 216382 24JUL63 PURINTON PRUDENCE VALENTINE
9 234967 21DEC67 SMITH GILBERT IRVINE
10 237642 13MAR54 BATTERSBY R. STEPHEN
11 239185 28AUG59 DOS REMEDIOS LEONARD WESLEY
12 254896 06APR49 TAYLOR-HUNYADI ITO MISHIMA
13 321783 03JUN35 GONZALES GUILLERMO RICARDO
14 328140 02JUN51 MEDINA-SIDONIA MARGARET ROSE
15 346917 15MAR50 SHIEKELESLAM SHALA Y.
16 356134 25OCT60 DUNNETT CHRISTINE MARIE
17 423286 31OCT64 MIFUNE YUKIO TOSHIRO
18 456910 24SEP53 ARDIS RICHARD BINGHAM
19 456921 12MAY62 KRAUSE KARL-HEINZ G.
20 457232 15OCT63 LOVELL WILLIAM SINCLAIR
21 459287 05JAN34 RODRIGUES JUAN M.
22 677890 24APR65 NISHIMATSU-LYNCH CAROL ANNE
23 245962 30AUG64 BEDORTHA KATHY MARTHA
For more information
about the APPEND procedure, see the
Base SAS Procedures Guide.