SASUnit Examples  Version 1.5.0
_getabspathcomponents.sas
Go to the documentation of this file.
1 
21 %MACRO _getAbsPathComponents (i_absPath =
22  ,o_fileName =
23  ,o_pathWithoutName =
24  );
25 
26  %LOCAL l_pathElementCount;
27  %LOCAL l_fileNameStartPos;
28 
29  %LET &o_fileName=;
30  %LET &o_pathWithoutName=;
31 
32  %IF "%sysfunc(compress(&i_absPath))" NE "" %THEN %DO; /*if not empty input string*/
33  %IF %sysfunc(index(&i_absPath.,/)) GT 0 %THEN %DO; /*input string contains dir separators*/
34  %LET l_pathElementCount=%sysfunc(countw(&i_absPath.,/));
35  %LET l_fileNameStartPos=%sysfunc(findw(&i_absPath.,%scan(&i_absPath,&l_pathElementCount,/)));
36  %LET &o_pathWithoutName=%sysfunc(substr(&i_absPath.,1,%EVAL(&l_fileNameStartPos. - 2)));
37  %LET &o_fileName = %sysfunc(substr(&i_absPath.,&l_fileNameStartPos.));
38  %END; /*IF %sysfunc(index(&i_absPath.,'/')) GT 0*/
39  %ELSE %DO; /*input string is a filename only*/
40  %LET &o_fileName = &i_absPath;
41  %END;
42  %END; /*IF "%sysfunc(compress(&i_absPath))" NE ""*/
43 
44 %MEND _getAbsPathComponents;