DATA Step, Macro, Functions and more

How to - Learn Size of Data Set By Using SAS Code?

Accepted Solution Solved
Reply
Super Contributor
Posts: 381
Accepted Solution

How to - Learn Size of Data Set By Using SAS Code?

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,


Accepted Solutions
Solution
‎12-02-2016 06:13 AM
Super User
Super User
Posts: 7,392

Re: How to - Learn Size of Data Set By Using SAS Code?

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


All Replies
Super User
Posts: 6,928

Re: How to - Learn Size of Data Set By Using SAS Code?

proc sql;
select filesize from dictionary.tables where libname = 'TEST' and memname = 'CARS';
quit;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 6,928

Re: How to - Learn Size of Data Set By Using SAS Code?

You can also run proc contents, the file size is found in the Engine/Host Dependent Information.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,392

Re: How to - Learn Size of Data Set By Using SAS Code?

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

Super Contributor
Posts: 381

Re: How to - Learn Size of Data Set By Using SAS Code?

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

Super User
Posts: 6,928

Re: How to - Learn Size of Data Set By Using SAS Code?

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎12-02-2016 06:13 AM
Super User
Super User
Posts: 7,392

Re: How to - Learn Size of Data Set By Using SAS Code?

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.

Super Contributor
Posts: 381

Re: How to - Learn Size of Data Set By Using SAS Code?

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 Smiley Happy

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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