We are still helping our customers get more out of the data they have and make data driven decisions. Our new site is packed with information and insights of how data can be the catalyst to your business growth.
The FINFO function can be used to gain a number of file attributes from the Windows file system. A total of six attributes named ‘info items’ can be identified through the use of the FINFO function and are formatted as below.
V = Variable, each record ends in a newline character.
F = Fixed, each record has the same length.
N = Binary, the file has no record boundaries.
P = Print, the SAS System write carriage-control characters.
D = Default Format (same as variable)
In order to access the info items for a single file, the FOPEN function must be used to return a file identifier for the file and allow the file to be opened for input. Once the file is opened the FINFO functions can be used to access the info items required. Finally, it is important to close the file using the SYSRC=FCLOSE function. This closes the file and outputs a system return code of 0 for a file that has been successfully closed or not 0 for a file that was unsuccessful.
The data for the Class Names file can be seen in the table below:
Sometimes it can be useful to gain the FINFO from a number of files in a directory. There are in total ten files stored within this location.
Three extra functions are available to make it possible to read in the FINFO from a directory of files. These functions are the DOPEN, DNUM and DREAD functions. When utilised effectively, they can be used to create a loop of all of the files within the directory in order to read the FINFO for each of the files. The DOPEN function similarly to the FOPEN function returns a directory identifier and allows the directory to be opened for input. The DNUM function can be used to count the number of files within the opened location which can be used within a do loop to loop through all of the files in the location. DREAD can then be utilised to read each file within this directory making each file accessible for the FOPEN and FINFO functions.
At the end of the process a DCLOSE function is available to close the directory after processing. The final data set contains all of the ten files stored within the location with the last modified date and file size in bytes for each file.