Try something like this:
%macro libraryProcMeans(library);
%macro a; %mEnd a; /* restores color coding in SAS Enterprise Guide */
/* Standardize capitalization of &library */
%let library = %upcase(&library);
/* Create space separated list of dataset names, and save
them into a macro variable named libraryList */
proc sql noPrint;
%local libraryList;
select memname
into :libraryList separated by ' '
from dictionary.tables
where libname="&library"
and memtype="DATA"
;
quit;
/* Loop over spaced separated items in &libraryList */
%local i next_name;
%let i=1;
%do %while (%scan(&libraryList, &i) ne );
%let next_name = %scan(&libraryList, &i);
%** DO whatever needs to be done for &NEXT_NAME;
title"&library..&next_name";
ods noProctitle;
proc summary data=&library..&next_name print;
run;
title;
ods procTitle;
%let i = %eval(&i + 1);
%end;
%mEnd libraryProcMeans;
/* To output to default location and PDF */
ods pdf file="FULL_FILE_PATH\FILE_NAME.pdf";
%libraryProcMeans(sashelp)
ods pdf close;
Though, you'll probably want to customize the PROC SUMMARY, or even replace it with a PROC MEANS.
Shout out to Cindy Puryear's blog post that helped me make this response
... View more