Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mfv_getpathuri.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Returns the uri of a file or folder
4 @details The automatic variable `_FILESRVC_[fref]_URI` is used after assigning
5 a fileref using the filesrvc engine.
6
7 Usage:
8
9 %put %mfv_getpathuri(/Public/folder/file.txt);
10 %put %mfv_getpathuri(/Public/folder);
11
12 @param [in] filepath The full path to the file on SAS drive
13 (eg /Public/myfile.txt)
14
15 <h4> SAS Macros </h4>
16 @li mf_abort.sas
17 @li mf_getuniquefileref.sas
18
19 <h4> Related Macros </h4>
20 @li mfv_existfile.sas
21 @li mfv_existfolder.sas
22
23 @version 3.5
24 @author [Allan Bowe](https://www.linkedin.com/in/allanbowe/)
25**/
26
27%macro mfv_getpathuri(filepath
28)/*/STORE SOURCE*/;
29
30 %mf_abort(
31 iftrue=(&syscc ne 0),
32 msg=Cannot enter &sysmacroname with syscc=&syscc
33 )
34
35 %local fref rc path name var /* var is used to avoid delete timing issue */;
36 %let fref=%mf_getuniquefileref();
37 %let name=%scan(&filepath,-1,/);
38 %let path=%substr(&filepath,1,%length(&filepath)-%length(&name)-1);
39
40 %if %sysfunc(filename(fref,,filesrvc,folderPath="&path" filename="&name"))=0
41 %then %do;
42 %let var=_FILESRVC_&fref._URI;
43 %str(&&&var)
44 %let rc=%sysfunc(filename(fref));
45 %symdel &var;
46 %end;
47 %else %do;
48 %put &sysmacroname: did not find &filepath;
49 %let syscc=0;
50 %end;
51
52%mend mfv_getpathuri;