SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
VijayKumar
Calcite | Level 5

Hi  Experts,

Could you please tell me the proc sql query in SAS  that will output the size of a table(in MB or GB)  in SAS ?

6 REPLIES 6
LinusH
Tourmaline | Level 20

By querying the SAS dictionary, you could get a approximate figure.

If the table is compressed, or has index, it's getting a bit more complex.

If you have tables in BASE engine you could read the OS information, pipe it back to (but this wouldn't be SQL).

Data never sleeps
LinusH
Tourmaline | Level 20

Sorry, forget sample code:

proc sql;

create table tab as

select libname, memname, nobs, obslen, nobs*obslen as Bytes

from dictionary.tables

where libname='YOURLIB';

quit;

Data never sleeps
jvp7
Calcite | Level 5

I want to know how to calculate the file size if the table has index. Could you help me, please?

Tom
Super User Tom
Super User

proc sql ;

  select libname,memname,filesize,pcompress

  from dictionary.tables

;

quit;

AllanBowe
Barite | Level 11
It's not a SQL query but it is a macro function - https://core.sasjs.io/mf__getfilesize_8sas.html

Usage: %put %mf_getfilesize(libds=work.yourdataset,format=yes);
/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
JackHamilton
Lapis Lazuli | Level 10
Does it have to be in PROC SQL? PROC CONTENTS will give you that information as well.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 6 replies
  • 13958 views
  • 3 likes
  • 6 in conversation