SAS Component Language Dictionary |
Returns the name of a SAS table column
var-name=VARNAME(table-id,var-num);
|
-
var-name
-
contains the name of the column.
Type: Character
-
table-id
-
is the identifier that was assigned when
the table was opened. If table-id is invalid,
the program halts.
Type: Numeric
-
var-num
-
is the number of the column in the opened
table referenced by the table-id. The VARNUM function returns this number.
Type: Numeric
Copy the names of the first five columns in the SAS
table CITY into an SCL variable. The column names are separated by blanks.
length varlist $ 80;
tableid=open('city','i');
varlist=' ';
do i=1 to min(5,attrn(tableid,'nvars'));
j=9*(i-1)+1;
substr(varlist,j,8)=varname(tableid,i);
end;
put varlist=;
rc=close(tableid);
VARNUM
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.