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>._all_ noprint out=temp (keep=memname); run; proc sort data=temp nodupkey; by memname; run; data _null_; set temp; call execute ('proc print data='|| memname || '(obs=10); title "*** ' || trim(memname) || ' ***"; run;'); 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.