BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
shivrajpawar98
Fluorite | Level 6

Hi All,

 

I want to run proc summary for all the datasets in one library and store it in on pdf file how can i do it.
Any help would be appreciated.

 

Regards,

Shivraj

1 ACCEPTED SOLUTION

Accepted Solutions
Al14
SAS Employee

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 solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Saying you want PROC SUMMARY results to go into a PDF file isn't specific enough. There are many choices of output that you can create from PROC SUMMARY. What specifically do you want from PROC SUMMARY to go in the PDF file?


Why do you need all of this in a PDF file anyway? These types of statistics can be stored in a SAS data set, where they would be much more useful in the long run.

 

Here is a way to obtain the names of all data sets in a library: https://communities.sas.com/t5/SAS-Programming/How-can-I-read-the-filenames-from-a-library-into-a-da...

 

Here is a way to create a data dictionary for all data sets in a library: https://communities.sas.com/t5/SAS-Communities-Library/Library-Datasets-Summary-Macro-DATA-SPECS/ta-...

--
Paige Miller
Al14
SAS Employee

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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 818 views
  • 2 likes
  • 3 in conversation