Search notes:

SAS programming, function varname

The following example uses attrn(…, nvars) to determine the number of variables in a data set and then iterates over the data set's variables and determins their name with varname.
%macro tq84_dataSetVarNames(ds);

  %local varList;

  %let fid = %sysFunc(open(&ds));

  %if &fid %then %do;
      %do i=1 %to %sysFunc(attrn(&fid, nvars));
          %let varList = &varList %sysFunc(varName(&fid, &i));
      %end;

      %let fid = %sysFunc(close(&fid));
  %end;

  &varList;

%mend tq84_dataSetVarNames;


%put %tq84_dataSetVarNames(tq84_ds); /* foo bar baz num */
Github repository about-SAS, path: /programming/functions/varname.sas

See also

Compare with vname which returns the name of a data step variable.
functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Companie...', 1759415520, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Companies-Products/SAS/programming/functions/varname(63): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78