Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve FileSize

Status
Not open for further replies.

mmignot

Programmer
Jul 16, 2001
44
US

Hello all,
I have a file that was created from a SAS data step that I need to check the file size on. Is there anyway I can do this in SAS?

Thanks,
Mark :)
 
Yes there is a way via SAS. First I would use the OS to let me know the size of a file before I would use SAS. On a DOS/Windows system you can use the 'dir' command and there is the equiv command on UNIX systems 'ls'.

Here is how I did it via SAS before I knew how to use the OS's information.

Code:
   filename _in "c:\your_file.txt";
   data _null_;    
     *** SET THE LRECL TO 1 SO THAT YOU CAN COUNT EACH BYTE ***;                              
     infile _in lrecl=1 recfm=F end=last;             
     input;
     ctr+1;
     if last then 
       put ctr=; *** HERE IS WHERE YOU CAN PUT ANY SAS STATEMENT ***;
   run;
 
Hello all,

I think I've got it figured out. Here is the code I used to retrieve a filesize. This was done on Unix:

Code:
   *--------------------------------------------*;
   * The following code will setup filename ref *;
   * for the LOC current months file. sizes from*;
   * Unix.                                      *;
   *--------------------------------------------*;
    data _null_;

     filename curloc pipe
      "ls -l &datdir./&testDir.data/loc&cur_file | 
       awk '{print $5}'";

   *--------------------------------------------*;
   * The following data step will retrieve and  *;
   * store the prior months file sizes for later*;
   * use.                                       *;
   *--------------------------------------------*;
    data curlocfile;
      infile curloc;
       input filesize $;
   
        c_loc_filsz = filesize;
        call symput('c_loc_filsz',c_loc_filsz);  
    run
    ;

   *--------------------------------------------*;
   * The following print step will print the    *;
   * file sizes for the LOC current months file.*;
   *--------------------------------------------*;
    proc print data=curlocfile;
      title "Current Month's LCO file";
    run
    ;

If anyone has a better method than what I posted, please
let me know.

Many thanks,
Mark :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top