Macros for SAS Application Developers
https://github.com/sasjs/core
ms_deletefile.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Deletes a file from SASjs Drive
4  @details Deletes a file from SASjs Drive, if it exists.
5 
6  Example:
7 
8  filename stpcode temp;
9  data _null_;
10  file stpcode;
11  put '%put hello world;';
12  run;
13  %ms_createfile(/some/stored/program.sas, inref=stpcode)
14 
15  %ms_deletefile(/some/stored/program.sas)
16 
17  @param [in] driveloc The full path to the file in SASjs Drive
18  @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
19 
20  <h4> SAS Macros </h4>
21  @li mf_getuniquefileref.sas
22 
23 **/
24 
25 %macro ms_deletefile(driveloc
26  ,mdebug=0
27  );
28 
29 %local headref;
30 %let headref=%mf_getuniquefileref();
31 
32 data _null_;
33  file &headref lrecl=1000;
34  infile "&_sasjs_tokenfile" lrecl=1000;
35  input;
36  put _infile_;
37 run;
38 
39 proc http method='DELETE' headerin=&headref
40  url="&_sasjs_apiserverurl/SASjsApi/drive/file?_filePath=&driveloc";
41 %if &mdebug=1 %then %do;
42  debug level=2;
43 %end;
44 run;
45 
46 filename &headref clear;
47 
48 %mend ms_deletefile;