If you are using SAS EG, i think there is no way to find out the libraries and the tables used int he program automatically, there is no in-built procedure.
However you can scan the whole code and find out which are the libraries and input or output.
other way could be to create a program which will read in your program as text file and create a dataset based on some keywords like - libname/filename/data/infile/merge etc.
In this way you could have some rows in the temp dataset which will show which libraries are there and corresponding tables, but it won't work sure shot for all input/outputs.
Filename inp "<path and name of the sas code/>";
data temp;
infile inp;
input rec $100.;
if index(lowcase(rec), "libname") ne 0 then output; /*check libraries */ else if index(lowcase(rec),"filename") ne 0 then output; /*check input files*/ else if index(lowcase(rec),"data") ne 0 and index(rec,".") ne 0 then output; /* to check the permanent datasets */ else if index(lowcase(rec),"merge") ne 0 and index(rec,".") ne o then output; /*check permanent datasets used in merge*/
run;
... View more