Language Reference |
adds observations to the end of a SAS data set
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.
The following statements show 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.
The following examples demonstrate the use of the APPEND statement. The first example shows the use of the FROM clause when creating a new data set. For more information, see the section "CREATE Statement". Here is the code:
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. Here is the code:
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 following statements:
dsvar={names sex}; create folks var dsvar; append;
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.