When program codes, applications and SAS data sets are developed, enough attention is often not given to EFFECIENCY, especially during the initial phases of development. Since, data size and system conduct can influence a program or an application’s functioning, SAS users need to access information about a data set’s size and content. To ascertain how much disk space a data set is using, users can easily do a few calculations to learn to access metadata content and attain the important information. Determine, estimate and understand information with this following tip, which helps improve SAS performance and fine-tuning of techniques.
Implementing PROC SQL and DICTIONARY.TABLES
The SAS system accumulates valuable information (also known as metadata) about all-familiar SAS libraries, indexes, data sets (tables), system options, views, catalogs, macros and an assemblage of other “read-only” tables called Dictionary tables and SASHELP views. TABLES, a particular Dictionary table and its SASHELP view equivalent, VTABLE, consists details about a SAS session’s data set. Check the following PROC SQL code as its specification will help us get access to the contents of four columns observed in the TABLES Dictionary table, namely BNAME, MEMNAME, MEMTYPE and FILESIZE to exhibit the size of the CARS data set.
PROC SQL and Dictionary.TABLES:
PROC SQL ; TITLE ‘Filesize for CARS Data Set’ ; SELECT LIBNAME, MEMNAME, FILESIZE FORMAT=SIZEKMG., FILESIZE FORMAT=SIZEK. FROM DICTIONARY.TABLES WHERE LIBNAME = ‘SASHELP’ AND MEMNAME = ‘CARS’ AND MEMTYPE = ‘DATA’ ; QUIT ;
The above results show that the CARS data set filesize is 192KB.
Nota bene: If the SIZEKMG.format is mentioned in a format=option, SAS ascertains whether it should apply KB for kilobytes, MB for megabytes or GB for gigabytes, and divide the filesize value with the help of one of the following values:
Using PROC PRINT and SASHELP.VTABLE
In the following example, the provisions of a PROC PRINT are explained to access the constituents of three columns found in the VTABLE SASHELP view, particularly LIBNAME, MEMNAME and FILESIZE to exhibit the size of the CARS data set.
PROC PRINT and SASHELP.VTABLE
PROC PRINT DATA=SASHELP.VTABLE NOOBS ; VAR LIBNAME MEMNAME FILESIZE ; WHERE LIBNAME = ‘SASHELP’ AND MEMNAME = ‘CARS’ ; FORMAT FILESIZE SIZEKMG. ; TITLE ‘Filesize for SASHELP.CARS Data Set’ ; RUN ;
Using DATA _NULL_, SASHELP.VEXTFL and CALL SYMPUTX
Lastly, a DATA_NULL_ is depicted to approach the contents of the VEXTFL SASHELP view with a FILENAME statement. An assignment statement is specified to determine the FILESIZE value for the size of the CARS data set. The CALL SYMPUTX left supports and chops off the trailing blanks from the digital FILSESIZE value of 196608.
Also read: Things to judge in SAS training centres
filename myfile 'C:\Program Files\SAS9.4\SASFoundation\9.4\\CORE\SASHELP\Cars.sas7bdat' ; DATA _NULL_ ; SET SASHELP.VEXTFL (WHERE=(FILEREF=’MYFILE’)) ; /* Calculate the Filesize in MB */ FILESIZE = FILESIZE / (1024 ** 2) ; CALL SYMPUTX (‘FILESIZE’,FILESIZE) ; RUN ;
This post originally appeared on – blogs.sas.com/content/sastraining/2017/04/25/determining-the-size-of-a-sas-data-set
Interested in a career in Data Analyst?
To learn more about Machine Learning Using Python and Spark – click here.
To learn more about Data Analyst with Advanced excel course – click here.
To learn more about Data Analyst with SAS Course – click here.
To learn more about Data Analyst with R Course – click here.
To learn more about Big Data Course – click here.