Search notes:

SAS programming: files

Iterate over attributes

/* Create a file: */
systask command "echo foo bar baz>/tmp/fbb.txt" wait shell='sh';

systask command "cat /tmp/fbb.txt" wait status=rc;

filename filref '/tmp/fbb.txt';
data _null_;
   fid = fopen('filref', 's');
   if fid = 0 then do;
      err = sysmsg();
      put err;
      abort;
   end;
   nofAttrs = foptnum(fid);
   put "File has " nofAttrs "attributes.";
/* Log: File has 6 attributes.
   .
   Iterate over each attribute: */
   do attrNo=1 to nofAttrs;
      attrName =foptname(fid, attrNo  );
      attrValue=finfo   (fid, attrName);
      put attrName @30 attrValue;
   end;
/*
   File has 6 attributes.
   Filename                     /tmp/fbb.txt
   Owner Name                   tq84
   Group Name                   users
   Access Permission            -rw-r--r--
   Last Modified                05Dec2017:15:37:32
   File Size (bytes)            12
*/
run;
filename filref clear;
Github repository about-SAS, path: /programming/files/iterate-attributes.sas
See also systask, foptnum, fopen, finfo

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...', 1759415522, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Companies-Products/SAS/programming/files/attributes(72): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78