Wednesday, October 18, 2006

Appending Files Efficiently

There are a couple of methods you can use to concatenate data sets. In these examples, work.step2 is appended to work.step1:

With a SET statement in a data step:
data work.step1;
set work.step1
work.step2;
run;

With the Datasets procedure:
proc datasets;
append base=work.step1
data=work.step2;
run;

When you use a SET statement, SAS must process all the observations in work.step1 and work.step2.

The APPEND statement bypasses the processing of the data in the original data set (work.step1) and adds the observations in work.step2 directly to the end of the original.

As a result, using the APPEND statement can be more efficient that using a SET statement if the BASE= dataset is large, and all variables in both data sets have the same variables and they are the same length and type.

The APPEND statement is very useful if you frequently add observations to SAS data sets.
Click here to learn more about the APPEND statement.

0 Comments:

Post a Comment

<< Home