Proc FMCP can be used to develop SAS functions and call routines an example is shown below

User Defined Functions

proc fcmp outlib=work.funcs.temp;
function laststr(instr $) $;
length outstr $2000;
outstr=reverse(scan(reverse(instr),
1,'\'));
return (outstr);
endsub;
run;

options cmplib=work.funcs;

data _null_;
path=
's:\this\is\a\test\path\testprog.sas';
progname=laststr(path);
put 'program   ' progname;
run;