FOPTNUM Function
Returns the number of information items, such as filename or record length, that are available for an external file.
| Category: | External Files |
|---|---|
| Restriction: | This function is not supported in a DATA step that runs in CAS. |
Table of Contents
Syntax
Required Argument
file-id
is the identifier that was assigned when the file was opened, generally by the FOPEN function.
Details
General Information
The number of information items that are available for a file depend on the operating environment and the type of file.
FOPTNUM Specifics under Linux
Under Linux, five information items are available for all types of files:
- Filename
- Owner Name
- Group Name
- Access Permission
- File Size (bytes)
If you concatenate filenames, then an additional information item–File List–is available. If you are using piped files, then the only information item that is available is the PIPE Command.
The open-mode specified in the FOPEN function determines the value that FOPTNUM returns.
|
Open Mode |
FOPTNUM Value |
Information Items Available |
|---|---|---|
|
Append Input Update |
6 for concatenated files 5 for single files |
All information items available. |
|
Output |
5 for concatenated files 4 for single files |
Because the file is open for output, the File Size information type is unavailable. |
|
Sequential (using Pipe Device Type) |
1 |
The only information item available is PIPE Command. |
For an example of how to use the FOPTNUM function, see File Attributes When Using the Pipe Device Type under Linux.
Comparisons
- Use FOPTNAME to determine the names of the items that are available for a particular operating environment.
- Use FINFO to retrieve the value of a particular information item.
Example
This example opens the external file with the fileref MYFILE and determines the number of system-dependent file information items available:
%let fid=%sysfunc(fopen(myfile));
%let infonum=%sysfunc(foptnum(&fid));
%let rc=%sysfunc(fclose(&fid));