In reply to Chris E.

Your approach depends on whether you're working forward from a root path to a certain level, or backwards from the file path to a certain level. Here's an example of working forward from a root path, using CALL SCAN to find the right cutoff level.

data _null_;
length name $ 255;
name = dequote(&_clientprojectpath);
call scan (name,4,cutoff,length,'\');
path = substr(name,1,cutoff-1);
call symput('libpath',path);
run;
%put &libpath;
libname source "&libpath.";