Prev: Authentic Designer Handbags EVOGUER.COM 15% OFF DISCOUNT!!!!
Next: Missing value with e8601dt. format
From: ash007 on 23 Nov 2009 11:09 Hello Sas-Users, Is it possible to retrieve the size of a dataset with a sas program. Thanks. Ash007.
From: Tom Abernathy on 23 Nov 2009 11:14 You can get size from PROC CONTENTS. You could use ODS to get it to write the size to a dataset. On Nov 23, 11:09 am, ash007 <ramsamyash...(a)gmail.com> wrote: > Hello Sas-Users, > > Is it possible to retrieve the size of a dataset with a sas program. > > Thanks. > > Ash007.
From: Michael Raithel on 23 Nov 2009 14:09 Dear SAS-L-ers, Ash007 posted the following: > > Is it possible to retrieve the size of a dataset with a sas program. > Ash, you didn't state what type of "dataset" for which you are looking to retrieve the size thereof. (How's that for murdering the King's English)?!?!?!? Assuming that it is a SAS data set that you have already LIBNAME-d, you could simply use the FILESIZE variable in the SASHELP.VTABL view. Neat, simple, and no messy OS commands to soil your pristine SAS program. If your "dataset" is not a SAS data set, then you may end up using some sort of OS command with either a FILENAME statement or a CALL SYSTEM command in a DATA _NULL_ step. Or, if you are on a directory-based OS, you may be able to use the F-team. The F-team is composed of the following six players: FILENAME, FOPEN, FOPTNUM, FOTPNAME, FOPTNAME, and FINFO; each of whom has his own function:-) Here is an example of putting the F-team into the game on a Windows workstation using SAS 9.2 for Windows XP: data info; length infoname infoval $60; drop rc fid infonum i close; rc=filename('abc','c:\temp\orsales.xls'); 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; proc print noobs data=info; run; In this example, the F-team determines the available information about the 'c:\temp\orsales.xls' file and writes it to a SAS data set. Among the things that the PRINT Procedure outputs is this tidbit: File Size (bytes) 141824 I'm sure that a clever Ash like yourself will easily be able to write code to get the F-team to do all of the work, then ignore the other file attributes and utilize File Size (bytes)! Ash, 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: MichaelRaithel(a)westat.com Author: Tuning SAS Applications in the MVS Environment Author: Tuning SAS Applications in the OS/390 and z/OS Environments, Second Edition http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=58172 Author: The Complete Guide to SAS Indexes http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=60409 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Men are in numberless instances qualified for certain things, for no other reason than because they are qualified for nothing else. - William Hazlitt +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
From: dkw0 on 23 Nov 2009 14:02
Tom Abernathy wrote: >On Nov 23, 11:09 am, ash007 <ramsamyash...(a)gmail.com> wrote: >> Hello Sas-Users, >> >> Is it possible to retrieve the size of a dataset with a sas program. > > You can get size from PROC CONTENTS. You could use ODS to get it to write the size to a dataset. And if you want it in a macro variable, here's a way: %macro get_nobs(data=); %local nobs; %let dsid=%sysfunc(open(&data)); %let nobs=%sysfunc(attrn(&dsid, NOBS)); %let rc=%sysfunc(close(&dsid)); &nobs %mend; %let n=%get_nobs(data=snd.case); |