SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 25289: Determine the Size of SAS Data Sets on PC, UNIX, VAX and Linux Servers

DetailsAboutRate It

When you are in the development stage of a project, it is often important to know how much disk space the production SAS data sets will take up. Knowing the eventual size of the data sets helps you to forecast how much disk space you will need to have available, and prevents you from coming up short.

When I want to size my SAS data sets in the Windows, VAX, UNIX and Linux environments, I use a simple SAS macro program that I developed, named size_the_data.sas. This macro program relies on two things:

  • The data set being sized must already exist in some form.
  • I must have an estimate of the number of observations that will eventually be stored in the data set.

By specifying the library name, SAS data set name and future number of observations in the program, I can get a projection of the SAS data set's future size. The estimate is specified in both data set pages and total data set bytes. The projection is accurate to within plus-or-minus a single data set page.

Macro Details

Program Name: Size_The_Data.sas

Purpose: This program calculates the future size of a SAS data set, based on its present characteristics and upon the projected number of observations (PROJOBS) that it will one-day contain.

Required Parameters:

LIBREF
This is the complete path to the directory that contains the existing SAS data set.
DSNAME
This is the name of the specific SAS data set that will be used as the template to calculate future data set size.
PROJOBS
The projected number of observations the data set will one-day contain.

The Program

******************************************************************************;
*                                                                            *;
* Program: Size_The_Data.sas                                                 *;
*                                                                            *;
* Author:  Michael A. Raithel                                                *;
*                                                                            *;
* Created: 12/26/2002                                                        *;
*                                                                            *;
******************************************************************************;

options macrogen symbolgen mprint mlogic source source2 nodate nonumber;

/********************************************************************/
/* Beginning of the SIZEDATA Macro.                                 */
/********************************************************************/
%MACRO SIZEDATA(libref=,dsname=,projobs=);


******************************************************************;
* Allocate the SAS Data Library.                                 *;
******************************************************************;
libname existing "&LIBREF";


******************************************************************;
* Determine the SAS data set size.                               *;
******************************************************************;
data calcfile;
set  sashelp.vtable(where=(libname='EXISTING' and
memname=upcase("&DSNAME")));

	projobs = &PROJOBS;
	obsperpg = floor(bufsize/obslen);
	totpages = 1 + ceil(projobs/obsperpg);
	totsize  = (totpages * bufsize);
	pagekilo = bufsize / 1024;
	call symput('PAGEKILO',pagekilo);

run;

******************************************************************;
* Create the report.                                             *;
******************************************************************;
proc print data=calcfile noobs label;
     var obslen projobs bufsize obsperpg totpages totsize;
title1 'Size Calculations From the SIZEDATA Macro';
title2 "SAS Data Library: &LIBREF";
title3 "SAS Data Set: &DSNAME";
label totpages = "Projected Number of &PAGEKILO K Pages"
      totsize  = 'Projected Data Set Size (Bytes)'
      projobs  = 'Projected Number of Observations'
      obsperpg = 'Projected Observations Per Page'
      bufsize  = 'Data Set Page Size'
      ;
format projobs totsize comma20.;
run;

/********************************************************************/
/* Ending of the SIZEDATA Macro.                                    */
/********************************************************************/
%MEND SIZEDATA;

/********************************************************************/
/* Invoke the SIZEDATA Macro.                                       */
/********************************************************************/
%SIZEDATA(libref=Q:\Data,dsname=filenams,projobs=6104);

Another Tip by Michael A. Raithel...

Programmatically Determine Which Disk Drives are Available for Your Windows Server or Workstation

Sample Output

                           Size Calculations From the SIZEDATA Macro
                                   SAS Data Library: Q:\Data
                                     SAS Data Set: filenams

                                     Data Set     Projected    Projected
Observation       Projected Number     Page     Observations   Number of     Projected Data Set
   Length          of Observations     Size       Per Page     4 K Pages           Size (Bytes)
   
     50                      6,104     4096          81            77                   315,392
	 

Michael says, "I hope that the size_the_data SAS macro program will help you seize the day when estimating the future size of your production SAS data sets!"

page divider

About the Author
Michael A. Raithel is a well-known, award-winning SUGI and NESUG speaker and contributor. He is the author of the Books By Users book Tuning SAS Applications in the OS/390 and z/OS Environments, Second Edition. A new edition is due out in August! Michael has used SAS software as a consultant and analyst for 17 years.




These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.