FOPTNAME Function: Windows

Returns the name of an information item for an external file.

Category: External Files
Windows specifics: available information items
See: FOPTNAME Function in SAS Functions and CALL Routines: Reference

Syntax

FOPTNAME(file-id, nval)

Required Arguments

file-id

specifies the identifier that was assigned when the file was opened, generally by the FOPEN function.

nval

specifies the number of the file information item to be retrieved. The following table shows the values that nval can have for single and concatenated files under Windows operating environments.

Information Items for Files
nval
Single File
Pipe Files
Concatenated Files
1
Filename
Unnamed pipe access device
Filename
2
RECFM
PROCESS
RECFM
3
LRECL
RECFM
LRECL
4
LRECL

Details

FOPTNAME returns a missing or null value if an invalid argument is used with FOPTNAME.

Example

The following example creates a data set that contains the name and value attributes that are returned by the FOPTNAME function when you are using pipes:
data fileatt;
   filename mypipe pipe 'dir';
   fid=fopen("mypipe","s");
   /* fid should be non—zero. 0 indicates failure */
   put "File id is: " fid=;
   numopts=foptnum(fid);
   put "Number of information items should be 4; " numopts=;
   do i=1 to numopts;
      optname=foptname(fid,i);
      put i= optname=;
      optval=finfo(fid,optname);
      put optval=;
   end;
rc=fclose(fid);
run;
The SAS LOG Displays Pipe File Information
NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds
6    data fileatt;
7       filename mypipe pipe 'dir';
8       fid=fopen("mypipe","s");
9       /* fid should be non-zero. 0 indicates failure */
10      put "File id is: " fid=;
11      numopts=foptnum(fid);
12      put "Number of information items should be 4; " numopts=;
13      do i=1 to numopts;
14         optname=foptname(fid,i);
15         put i= optname=;
16         optval=finfo(fid,optname);
17         put optval=;
18      end;
19
20   rc=fclose(fid);
21   run;
File id is: fid=1
Number of information items should be 4; numopts=4
i=1 optname=Unnamed Pipe Access Device
optval=
i=2 optname=PROCESS
optval=dir
i=3 optname=RECFM
optval=V
i=4 optname=LRECL
optval=32767
NOTE: The data set WORK.FILEATT has 1 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           9.64 seconds
      cpu time            1.16 seconds
22   proc printto; run;