Chapter Contents

Previous

Next
FILEREF

FILEREF



Verifies that a fileref has been assigned for the current SAS session or process

Category: External File


Syntax
Details
Examples
Example 1: Determining Whether a Fileref Has Been Assigned to an External File
Example 2: Determining Whether a Fileref and Its File Exist
See Also

Syntax

sysrc=FILEREF(fileref);

sysrc
contains the return code for the operation:
0 Both the fileref and the external file exist.
< 0 The fileref has been assigned, but the file that it points to does not exist.
> 0 The fileref has not been assigned.

Type: Numeric

fileref
is the fileref to be validated (up to eight characters).

Type: Character


Details

A negative return code indicates that the fileref exists but that the physical file associated with the fileref does not exist. A positive, nonzero value indicates that the fileref has not been assigned.

A fileref can be assigned to an external file by using the FILENAME statement or the FILENAME function in SCL. Under some operating systems, you can also use system commands to assign filerefs. See the SAS documentation for your operating environment.


Examples

Example 1: Determining Whether a Fileref Has Been Assigned to an External File

Test whether the fileref MYFILE is currently assigned to an external file. A system error message is issued if the fileref is not currently assigned.

if (fileref('myfile') > 0) then _msg_=sysmsg();

Example 2: Determining Whether a Fileref and Its File Exist

Test the fileref MYFILE to determine whether the fileref is assigned and whether the file that it refers to exists:

if (fileref('myfile') ne 0) then _msg_=sysmsg();

See Also

FEXIST

FILEEXIST

FILENAME

PATHNAME


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.