Hello everyone,
I would like to learn the size of specific data sets.
For example; after I wrote the following code, I went to C:\Test path and learnt the size of data set is 192 KB.
Libname Test "C:\Test";
Data Test.Cars;
Set Sashelp.Cars;
Run;
But my question is how can I learn the size of Sas data set by using SAS code? Is it possible?
Thank you,
Hi,
SASHELP is a library with various datasets and view within. VTABLE is one of the SAS system metadata views (a view being code which pulls data from other datasets). You can use this in any way you would another view (more or less like a dataset), so you could do:
data want; set sashelp.vtable (where=(libname="WORK" and memname="MYDATA")); run;
You can open it from the eplorer window in SAS to see what is contained. You also have VCOLUMN which has the structure of each dataset, and various other Vxxx views which all contain useful metadata.
Why exactly do you need this information by the way? Generally speaking know how many bytes a file takes isn't particularly useful for anyone above system level, for us, observation and column numbers are important.
proc sql;
select filesize from dictionary.tables where libname = 'TEST' and memname = 'CARS';
quit;
You can also run proc contents, the file size is found in the Engine/Host Dependent Information.
Just to add you can also look at SASHELP.VTABLES.
Hello,
Thank you for your responses,
When I try to use the following code it brings the following output
proc sql;
select filesize from dictionary.tables where libname = 'SASHELP' and memname = 'CARS';
quit;
When I try to use Contents it brings following output but when I check the Engine/Host Dependent Information part, I cannot see any information about size of data set, can you lead me?
About the Sashelp.VTables subject can you give me a detailed information, maybe you can share sample code?
Thank you
Oh, you're on a toybox aka Windows.
On UNIX, SAS reports the size:
Engine/Host Dependent Information Data Set Page Size 16384 Number of Data Set Pages 5 First Data Page 1 Max Obs per Page 107 Obs in First Data Page 82 Number of Data Set Repairs 0 Filename /usr/local/SAS/SASFoundation/9.2/sashelp/cars.sas7bdat Release Created 9.0202M0 Host Created AIX Inode Number 423566 Access Permission rw-r--r-- Owner Name sas File Size (bytes) 90112
So you may have to rely on the data from dictionary.tables or sashelp.vtable (which is a view on dictionary.columns), or you use a directory listing of the library.
Hi,
SASHELP is a library with various datasets and view within. VTABLE is one of the SAS system metadata views (a view being code which pulls data from other datasets). You can use this in any way you would another view (more or less like a dataset), so you could do:
data want; set sashelp.vtable (where=(libname="WORK" and memname="MYDATA")); run;
You can open it from the eplorer window in SAS to see what is contained. You also have VCOLUMN which has the structure of each dataset, and various other Vxxx views which all contain useful metadata.
Why exactly do you need this information by the way? Generally speaking know how many bytes a file takes isn't particularly useful for anyone above system level, for us, observation and column numbers are important.
Thank you both of you,
As you told me number of observations&columns are more important but sometimes I need to know the size of the file.
Thank you for these useful information and codes 🙂
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!
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.
Ready to level-up your skills? Choose your own adventure.