SAS Component Language Dictionary |
Returns the number of a SAS table column
var-num=VARNUM(table-id,var-name);
|
-
var-num
-
contains the position number of the
column in the SAS table, or 0 if the column is not in the SAS table.
Type: Numeric
-
table-id
-
is the identifier that was assigned
when the table was opened. If table-id is invalid,
the program halts.
Type: Numeric
-
var-name
-
is the name of the column.
Type: Character
VARNUM returns the number of a SAS table
column.
Obtain the number of a column in the SAS
table MYDATA, using the value of the NAME variable:
tableid=open('mydata','i');
if (sasname(name)) then do;
citynum=varnum(tableid,name);
if (citynum=0) then
_msg_='The column is not in the table.';
else
_msg_='The column number is '|| citynum;
end;
else
_msg_='Invalid SAS name--please reenter.';
VARNAME
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.