Sample 24834: Concatenating SAS Data Sets with the APPEND Procedure
The APPEND procedure is an efficient method for concatenating observations from a smaller data set to a larger data set. The BASE= data set option is reserved for the larger of the two data sets with the DATA= option for the smaller data set. Essentially, the APPEND procedure avoids reading any observations in the BASE= data set by positioning the record pointer at the end of the BASE= data set. Each observation from the smaller data set is then applied one at a time to the end of the BASE= data set.
In the next example, the BASE= data set identifies a larger data set called MASTER and the DATA= data set identifies the smaller TXN data set. Note: When one or more variables in the input data set (DATA=) are not present in the BASE= data set, an optional FORCE option can be specified as an option with the PROC APPEND statement to prevent a syntax error.
PROC APPEND
BASE=master
DATA=txn;
RUN;
|
When two or more data sets need to be concatenated, multiple APPEND procedures are issued. In the next example, two separate PROC APPEND steps are specified to concatenate the two smaller data sets (txn1 and txn2) at the end of the larger BASE= data set.
PROC APPEND
BASE=master
DATA=txn1;
RUN;
PROC APPEND
BASE=master
DATA=txn2;
RUN;
|

About the Author
If you would like more information or have any questions about this tip, please contact Kirk Lafler, Software Intelligence Corporation at KirkLafler@cs.com. Kirk's new book, Power SAS: A Survival Guide is published by Apress and provides SAS users with the largest and most comprehensive collection of SAS tips and techniques ever offered. Power SAS can be purchased on Amazon.com and BarnesandNoble.com.
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.
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 shows how to concatenate two SAS data sets using PROC APPEND.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> APPEND Non SAS Authors ==> Kirk Paul Lafler
|
| Date Modified: | 2005-02-01 08:47:35 |
| Date Created: | 2004-10-15 08:36:56 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |