Search notes:

SAS programming, function fdelete

The following example uses fexist to check whether a file exists. If this is the case, it deletes it using fdelete.
Note: fdelete and fexist operate on filerefs, not on physical operating system path names. Therefore, the macro also uses a filename statement to assign the filref.
%macro deleteFile(fileName);
  filename fnam "&fileName";
  data _null_;
    if fexist("fnam") then do;
       put "&fileName exists, going to delete it.";
       rc = fdelete("fnam");
    end;
    else do;
       put "&fileName does not exist.";
       put "Nothing to do!";
    end;
  run;
  filename fnam clear;
%mend  deleteFile;

systask command "touch /tmp/tq84.txt" wait;
%deleteFile(/tmp/tq84.txt)
%deleteFile(/tmp/tq84.txt)
Github repository about-SAS, path: /programming/functions/fdelete/delete-file-if-it-exists.sas

See also

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