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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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