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);
|
|
|
|