2

Does anyone know of any SAS functions / techniques for obtaining the SIZE of files / datasets in UNIX directories? (eg in MB or GB).

flag

4 Answers

1

Hello,

You can use this code coming from sashelp documentation to receive in a table the size of files in blocks (=byte), divide it by 10*6 to get the size in megabytes.

Kind regards,
Toloc

RSUBMIT;
filename oecmd pipe 'ls -l your_directory';

data dirlist;
infile oecmd truncover;
input mode $ 1-10 nlinks 12-14 user $ 16-23
group $25-32 size 34-40 lastmod $ 42-53
name $ 54-253;
run;
ENDRSUBMIT;

link|flag
0

You can use the FINFO function to extract information about individual files:

libname mytmp '/tmp';

data mytmp.mydata;
  x='First';
  y=1;
  output;
  x='Second';
  y=2;
  output;
run;


data info;
  length infoname infoval $60;
  drop rc fid infonum i close;
  rc=filename('abc','/tmp/mydata.sas7bdat');
  fid=fopen('abc');
  infonum=foptnum(fid);
  do i=1 to infonum;
     infoname=foptname(fid,i);
     infoval=finfo(fid,infoname);
     output;
  end;
  close=fclose(fid);
run;

After running this piece of SAS code, the data set "info" contains records about various file informations for /tmp/mydata.sas7bdat. This could be any type of file though. One information item is file size in bytes.

link|flag
0

You can use the CONTENTS procedure mixed with the ODS system:

title1 "PROC CONTENTS ODS Output";

options nodate nonumber nocenter formdlim='-';

data a;
   x=1;
run;


ods output enginehost=eng;

ods listing close;

proc contents details data=a;
run;

ods listing;

After running this piece of SAS code, the data set "eng" contains information item records about the data set "a". This works for SAS member files (SAS data sets etc.), and gives various engine information about the selected member. One of the information items is file size in bytes.

link|flag
0

You can use the DATASETS procedure together with the ODS system:

ODS OUTPUT members = mmbrs ;

PROC DATASETS details library = SASHELP;
RUN; quit ;

proc print DATA=mmbrs NOobs n; run;

The "FileSize" column in the output data set "mmbrs" holds the file size of the SAS members.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.