Parsing in SAS for a keyword

sas

#1

I am trying to parse all libnames along with their path in a sas code and output that to excel.
The objective is to have a unique libname assigned to a particular path across all the codes.
I am trying to do this using substr function to search for libnames and ods to excel.
Can someone suggest a different approach for this problem?