BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
turcay
Lapis Lazuli | Level 10

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,

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

View solution in original post

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Just to add you can also look at SASHELP.VTABLES.

turcay
Lapis Lazuli | Level 10

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;

SizeOfFile.png

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?

 

EngineHost.png

 

About the Sashelp.VTables subject can you give me a detailed information, maybe you can share sample code?

 

Thank you

Kurt_Bremser
Super User

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

turcay
Lapis Lazuli | Level 10

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 🙂

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1947 views
  • 5 likes
  • 3 in conversation