Language Reference |
CONTENTS Function |
The CONTENTS function returns a column vector that contains the variable names for a SAS data set. The vector contains rows, where is the number of variables in the data set. The variable list is returned in the order in which the variables occur in the data set.
You can specify the SAS data set with a one-level name (for example, A) or with a libref and a SAS data set name (for example, Sashelp.Class). If you specify a one-level name, SAS/IML software uses the default SAS data library (as specified in the DEFLIB= option in the RESET statement.) If no arguments are specified, the current open input data set is used.
The following statements use the CONTENTS function to obtain the names of variables in SAS data sets:
x = 1:5; create temp from x; append from x; tempVars = contents(); /* use current open input data set */ close temp; classVars = contents("sashelp", "class"); /* contents of data set in */ /* SASHELP library */ print tempVars classVars;
See also the description of the SHOW CONTENTS statement.
Copyright © SAS Institute, Inc. All Rights Reserved.