VARNAME Function

Returns the name of a SAS data set variable.

Category: SAS File I/O


Required Arguments


specifies the data set identifier that the OPEN function returns.


specifies the number of the variable's position in the SAS data set.

Tips This number is next to the variable in the list that is produced by the CONTENTS procedure.
The VARNUM function returns this number.


This example copies the names of the first five variables in the SAS data set CITY (or all of the variables if there are fewer than five) into a macro variable.
%macro names;
   %let dsid=%sysfunc(open(city,i));
   %let varlist=;
   %do i=1 %to
      %let varlist=&varlist %sysfunc(varname
   %put varlist=&varlist;
%mend names;

See Also