Language Reference |
creates a new SAS data set
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 */You can specify a COLNAME= and a ROWNAME= matrix in the FROM clause. The COLNAME= matrix gives names to variables in the SAS data set being created. The COLNAME= operand specifies the name of a character matrix. The first ncol values from this matrix provide the variable names in the data set being created, where ncol is the number of columns in the FROM matrix. The CREATE statement uses the first ncol elements of the COLNAME= matrix in row-major order.
The ROWNAME= operand adds a variable to the data set to contain row titles. The operand must be a character matrix that exists and has values. The length of the data set variable added is the length of a matrix element of the operand. The same ROWNAME= matrix should be used in any subsequent APPEND statements for this data set.
The variable types and lengths are the current attributes of the matrices specified in the VAR clause or the matrix in the FROM clause. The default type is numeric when the name is undefined and unvalued. The default, when no variables are specified, is all active variables. To add observations to your data set, you must use the APPEND statement.
For example, the following statements create a new SAS data set CLASS having variables NAME, SEX, AGE, HEIGHT, and WEIGHT. The data come from IML matrices with the same names. You must initialize the character variables (NAME and SEX) and set the length prior to invoking the CREATE statement. NAME and SEX are character variables of lengths 12 and 1, respectively. AGE, HEIGHT, and WEIGHT are, by default, numeric.
name="123456789012"; sex="M"; create class var {name sex age height weight}; append;In the next example, you use the FROM clause with the COLNAME= operand to create a SAS data set named MYDATA. The new data set has variables named with the COLNAME= operand. The data are in the FROM matrix , and there are two observations because has two rows of data. The COLNAME= operand gives descriptive names to the data set variables. Here is the code:
x={1 2 3, 4 5 6}; varnames='x1':'x3'; /* creates data set MYDATA with variables X1, X2, X3 */ create mydata from x [colname=varnames]; append from x;
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.