Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Language Reference

APPEND Statement

adds observations to the end of a SAS data set

APPEND < VAR operand > ;
APPEND < FROM from-name < [ROWNAME=row-name] > > ;

In the preceding statements,
operand
can be specified as one of the following:

from-name
is the name of a matrix containing data to append.

row-name
is a character matrix or quoted literal containing descriptive row names.

Use the APPEND statement to add data to the end of the current output data set. The appended observations are from either the variables specified in the VAR clause or variables created from the columns of the FROM matrix. The FROM clause and the VAR clause should not be specified together.

You can specify a set of variables to use with the VAR clause.

Below are examples showing each possible way you can use the VAR clause.

var {time1 time5 time9}; /* a literal giving the variables */
var time;                /* a matrix containing the names  */
var('time1':'time9');    /* an expression                  */
var _all_;               /* a keyword                      */
If the VAR clause includes a matrix with more than one row and column, the APPEND statement adds one observation for each element in the matrix with the greatest number of elements. Elements are appended in row-major order. Variables in the VAR clause with fewer than the maximum number of elements contribute missing values to observations after all of their elements have been used.

The default variables for the APPEND statement are all matrices that match variables in the current data set with respect to name and type.

The ROWNAME= operand to the FROM clause specifies the name of a character matrix to contain row titles. The first nrow values of this matrix become values of a variable with the same name in the output data set; nrow is the number of rows in the FROM matrix. The procedure uses the first nrow elements in row-major order.

Examples using the APPEND statement follow. The first example shows the use of the FROM clause when creating a new data set. See also the section "CREATE Statement"

   x={1 2 3, 4 5 6};
   create mydata from x[colname={x1 x2 x3}];
   append from x;
   show contents;
      /* shows 3 variables (x1 x2 x3) and 2 observations */
The next example shows the use of the VAR clause for selecting variables from which to append data.
   names={'Jimmy' 'Sue' 'Ted'};
   sex={m f m};
   create folks var{names sex};
   append;
   show contents;
   /* shows 2 variables (names,sex) and 3 observations in FOLKS */
You could achieve the same result with the statements
   dsvar={names sex};
   create folks var dsvar;
   append;

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.