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