Table of Contents
The PROC APPEND statement is a powerful tool in SAS that allows users to combine data sets efficiently and effectively. This statement is particularly useful when working with large amounts of data or when needing to merge data sets with different variables.
To use the PROC APPEND statement, the user must first specify the data sets to be merged and the location where the resulting merged data set will be saved. The statement then appends the data sets together, creating a new data set that contains all the observations and variables from the original data sets.
For example, if a user wants to merge two data sets, “SalesData1” and “SalesData2”, the PROC APPEND statement would look like this:
PROC APPEND BASE=SalesData1
DATA=SalesData2;
RUN;
This would create a new data set called “SalesData1” which would contain the observations and variables from both “SalesData1” and “SalesData2”.
In addition, the PROC APPEND statement allows users to specify options such as whether to keep or drop variables, or whether to keep or replace duplicate observations. This provides users with more control over the merging process.
In conclusion, the PROC APPEND statement in SAS is a useful and efficient tool for combining data sets. It can save time and effort when working with large amounts of data and allows for customization of the merging process.
Use Proc Append in SAS (With Examples)
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 appendbase=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 printdata=data1;
proc printdata=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 appendbase=data1
data=data2;
run;
/*view updated data1*/
proc printdata=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 appendbase=data1
data=data2
force;
run;
/*view updated data1*/
proc printdata=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 .
Additional Resources
The following tutorials explain how to perform other common tasks in SAS:
Cite this article
stats writer (2024). How do I use the PROC APPEND statement in SAS? Can you provide examples?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-do-i-use-the-proc-append-statement-in-sas-can-you-provide-examples/
stats writer. "How do I use the PROC APPEND statement in SAS? Can you provide examples?." PSYCHOLOGICAL SCALES, 30 Jun. 2024, https://scales.arabpsychology.com/stats/how-do-i-use-the-proc-append-statement-in-sas-can-you-provide-examples/.
stats writer. "How do I use the PROC APPEND statement in SAS? Can you provide examples?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-do-i-use-the-proc-append-statement-in-sas-can-you-provide-examples/.
stats writer (2024) 'How do I use the PROC APPEND statement in SAS? Can you provide examples?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-do-i-use-the-proc-append-statement-in-sas-can-you-provide-examples/.
[1] stats writer, "How do I use the PROC APPEND statement in SAS? Can you provide examples?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How do I use the PROC APPEND statement in SAS? Can you provide examples?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
