SUPPORT / SAMPLES & SAS NOTES
 

Support

Usage Note 38267: Retrieving the file ID and other file information using the FINFO function in SAS® 9.2.

DetailsAboutRate It

In SAS 9.2, the FINFO function (in conjunction with the FOPEN and FCLOSE functions) retrieves system information from a file. You provide the file ID (that is assigned when the file is opened with the FOPEN function) and the name of the file information item that you want to retrieve, as shown in the following syntax:

FINFO(file-id,info-item)

The available information items (or, attributes) depend on the operating environment and the SAS release. If you do not know the available attributes, you can use the FOPTNUM and FOPTNAME functions to identify those attributes for use with the FINFO function.

The following example uses all five functions (FOPEN, FOPTNUM, FOPTNAME, FINFO, and FCLOSE) to retrieve available attributes and their values. Of course, you can simplify the program if you already know which attributes (for example, File Size(bytes) or Last Modified) that you want to retrieve.

data info; length infoname infoval $60; drop rc fid infonum i close; rc=filename("abc","c:\temp\mon3.dat"); 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 data=info; title1 "Attributes obtained for a file"; run;

In a Windows operating environment, the output appears as follows:

infoname             infoval

Filename             c:\temp\mon3.dat
RECFM                V
LRECL                256
File Size (bytes)    332
Last Modified        05May2009:10:44:23
Create Time          04May2009:17:04:22

Output from same program run in SAS® 9.1.3 (fewer attributes are available – not very useful):

infoname     infoval

File Name    c:\temp\mon3.dat
RECFM        V
LRECL        256



Operating System and Release Information

Product FamilyProductSystemProduct ReleaseSAS Release
ReportedFixed*ReportedFixed*
SAS SystemBase SASMicrosoft® Windows® for 64-Bit Itanium-based Systems9.219.2 TS2M3
Microsoft Windows Server 2003 Datacenter 64-bit Edition9.219.2 TS2M3
Microsoft Windows Server 2003 Enterprise 64-bit Edition9.219.2 TS2M3
Microsoft Windows XP 64-bit Edition9.219.2 TS2M3
Microsoft® Windows® for x649.219.2 TS2M3
Microsoft Windows Server 2003 Datacenter Edition9.219.2 TS2M3
Microsoft Windows Server 2003 Enterprise Edition9.219.2 TS2M3
Microsoft Windows Server 2003 Standard Edition9.219.2 TS2M3
Microsoft Windows Server 20089.219.2 TS2M3
Microsoft Windows XP Professional9.219.2 TS2M3
Windows 7 Enterprise 32 bit9.219.2 TS2M3
Windows 7 Enterprise x649.219.2 TS2M3
Windows 7 Home Premium 32 bit9.219.2 TS2M3
Windows 7 Home Premium x649.219.2 TS2M3
Windows 7 Professional 32 bit9.219.2 TS2M3
Windows 7 Professional x649.219.2 TS2M3
Windows 7 Ultimate 32 bit9.219.2 TS2M3
Windows 7 Ultimate x649.219.2 TS2M3
Windows Vista9.219.2 TS2M3
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.