LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 2 Oct 2009 10:50:07 -0400
Reply-To:     Randy Herbison <RandyHerbison@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Randy Herbison <RandyHerbison@WESTAT.COM>
Subject:      Re: Is there any way to check the filesize(e.g. kb or mb) in SAS?
In-Reply-To:  <>
Content-Type: text/plain; charset="us-ascii"

FINFO should be an available option, but it doesn't seem to return the file size attribute when using SAS 9.1.3 on XP. It does return the file size when using SAS 9.2 on XP.


-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Michael Raithel Sent: Friday, October 02, 2009 10:26 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Is there any way to check the filesize(e.g. kb or mb) in SAS?

Dear SAS-L-ers,

Amar Mundankar posted the following:

> > Hi all, > Suppose there is one flat file and I want to read the contents of that > file. > Also i want to store its size in one variable. > Is there any way to do that? > > eg. The contents of a file are: > > Id var1 > 1 abc > 2 xyz > > dataset want should have 3 variables. 3rd variable will be size of the > file, which will be same for 2 records.: > Id var1 size > 1 abc "size in kb " > 2 xyz "size in kb " > Amar, I do not remember seeing a reply to your query. So, here is one coming at you from the overcast, but nonetheless lovely, Washington DC suburbs:)

The thing that I am addressing in this missive is determining the size of the file, and I can think of two ways to do this:

1. Use the FILENAME statement to execute a system command that gets file information--including size--and input it into your SAS program. I do something along these lines in my ancient SUGI 30 paper: Automatically Process a Varying Number Of New Data Files From a "Data Directory"

..though it is not the thrust of the paper. See the description of the IDENTIFY SAS Macro on page three, including an example FILENAME that you can slice-and-dice to your specifications-especially getting rid of the "/b" option for your own needs!

2. Using the FOPEN, FOPTNUM, FOPTNAME, and-especially-the FINFO functions to get file attributes. You can read all about it in the SAS Online documentation; starting with this stellar example right about here:

I hope that this gives you something to chew on besides your breakfast!

Amar, best of luck in all of your SAS endeavors!

I hope that this suggestion proves helpful now, and in the future!

Of course, all of these opinions and insights are my own, and do not reflect those of my organization or my associates. All SAS code and/or methodologies specified in this posting are for illustrative purposes only and no warranty is stated or implied as to their accuracy or applicability. People deciding to use information in this posting do so at their own risk.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Michael A. Raithel "The man who wrote the book on performance" E-mail:

Author: Tuning SAS Applications in the MVS Environment

Author: Tuning SAS Applications in the OS/390 and z/OS Environments, Second Edition

Author: The Complete Guide to SAS Indexes

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Don't play the game; game the play! - Michael A. Raithel +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Back to: Top of message | Previous page | Main SAS-L page