This code was found here. It lets you loop through datasets in a SAS-library and tries to print the first 10 observations from each dataset in the SAS-library.
proc contents data=<Your library> noprint out=temp (keep=memname);
call execute (‘proc print data=’|| memname || ‘(obs=10); title “*** ‘ || trim(memname) || ‘ ***”; run;’);
Call Execute lets you run PROC-statements in a datastep. It will simply execute the proc-statement after finishing the datastep. It is also possible to use ‘if‘, ‘then‘ and ‘else‘ in the datastep to execute certain parts of the code based on some value.
This is of course also possible through macro-code.