How to use Proc Append in SAS (With Examples)

Proc Append is a SAS procedure that enables you to combine two or more SAS data sets into one. This is done by adding the observations from one data set to the end of an existing data set. This is often used to combine data from multiple sources into a single data set. An example of how to use Proc Append is to combine two data sets called ‘Data1’ and ‘Data2’ into one data set called ‘Data Combined’. To do this, you would use the following code: proc append base=DataCombined data=Data1,Data2; run; This code will combine the observations from Data1 and Data2 into Data Combined.


You can use PROC APPEND in SAS to append the values of one dataset to the end of another dataset.

This procedure uses the following basic syntax:

proc append
    base=data1
    data=data2;
run;

Note that this procedure doesn’t create a new dataset. Rather, it automatically appends the values in data2 to the end of data1.

The following example shows how to use this procedure in practice.

Example: Using Proc Append in SAS

Suppose we have the following two datasets in SAS:

/*create datasets*/
data data1;
    input team $ points rebounds;
    datalines;
A 25 10
B 18 4
C 18 7
D 24 12
E 27 11
;
run;

data data2;
    input team $ points rebounds;
    datalines;
F 26 8
G 30 4
H 27 9
I 21 12
J 20 6
;
run;

/*view datasets*/
proc print data=data1;
proc print data=data2;

We can use the following PROC APPEND statement to append the values of data2 to the end of data1:

/*append data2 to end of data1*/
proc append
    base=data1
    data=data2;
run;

/*view updated data1*/
proc print data=data1;

We can see that the values of data2 have been added to the end of data1. The dataset data1 now contains 10 total observations.

It’s important to note that you’ll receive the following error message if you attempt to use PROC APPEND when the two datasets have different column names:

ERROR: No appending done because of anomalies listed above.
       Use FORCE option to append these files.

In this situation, you can either change the column names to match or you can use the force argument to force the append procedure.

For example, suppose the second dataset had a variable name of “rebound” instead of “rebounds.”

/*append data2 to end of data1*/
proc append
    base=data1
    data=data2
    force;
run;

/*view updated data1*/
proc print data=data1;

Notice that data2 has been appended to data1, but the values in the rebounds column are empty for the appended dataset.

Note: You can find the complete documentation for PROC APPEND .

The following tutorials explain how to perform other common tasks in SAS:

x