mfv_getfolderpath.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Returns the path of a folder from the URI
4  @details Makes use of the SYSMSG() ER8OR response, which resolves the uri,
5  seemingly without entering an er8or state.
6 
7  Usage:
8 
9  %mv_createfolder(path=/public/demo)
10  %let uri=%mfv_getpathuri(/public/demo);
11  %put %mfv_getfolderpath(&uri);
12 
13  Notice above the new path has an uppercase P - the correct path.
14 
15  @param [in] uri The uri of the folder -eg /folders/folders/xxxx)
16 
17  <h4> SAS Macros </h4>
18  @li mf_getuniquefileref.sas
19 
20  <h4> Related Macros </h4>
21  @li mfv_getpathuri.sas
22 
23  @version 4
24  @author [Allan Bowe](https://www.linkedin.com/in/allanbowe/)
25 **/
26 %macro mfv_getfolderpath(uri
27 )/*/STORE SOURCE*/;
28 
29  %local fref rc path msg var /* var used to avoid delete timing issue */;
30  %let fref=%mf_getuniquefileref();
31  %if %quote(%substr(%str(&uri),1,17)) ne %quote(/folders/folders/)
32  %then %do;
33  %put &sysmacroname: Invalid URI: &uri;
34  %end;
35  %else %if %sysfunc(filename(fref,,filesrvc,folderuri="&uri" ))=0
36  %then %do;
37  %let var=_FILESRVC_&fref._URI;
38  %local fid ;
39  %let fid= %sysfunc(fopen(&fref,I));
40  %let msg=%quote(%sysfunc(sysmsg()));
41 
42  %unquote(%scan(&msg,2,%str(,.)))
43 
44  %let rc=%sysfunc(fclose(&fid));
45  %let rc=%sysfunc(filename(fref));
46  %symdel &var;
47  %end;
48  %else %do;
49  %put &sysmacroname: Not Found: &uri;
50  %let syscc=0;
51  %end;
52 
53 %mend mfv_getfolderpath ;