Functions and CALL Routines under UNIX |
Category: | External Files |
UNIX specifics: | fileref can be assigned with an environment variable; valid values of device-type and host-options |
See: | FILENAME Function in SAS Language Reference: Dictionary |
Syntax | |
Details |
Syntax |
FILENAME(fileref, filename <,device-type<,"host-options"<,dir-ref>>>) |
specifies the fileref to assign to an external file. In a DATA step, fileref can be a character expression, a string enclosed in quotation marks, or a DATA step variable whose value contains the fileref. In a macro (for example, in the %SYSFUNC function), fileref is the name of a macro variable (without an ampersand) whose value contains the fileref to assign to the external file. (For information, see the FILENAME function in SAS Language Reference: Dictionary.)
Under UNIX, the fileref can be a UNIX environment variable. The fileref or the environment variable that you specify must be enclosed in double quotation marks.
specifies the external file. Specifying a blank filename (" ") deassigns a fileref that was previously assigned.
Under UNIX, the filename differs according to the device type. See Device Information in the FILENAME Statement for information that is appropriate for each device. Remember that UNIX filenames are case sensitive.
In a DATA step, filename can be a character expression, a string enclosed in quotation marks, or a DATA step variable whose value contains the filename. In a macro, filename can be any expression.
specifies the type of device or the access method that is used if the fileref points to an input or output device or location that is not a physical file. It can be any one of the devices listed in Device Information in the FILENAME Statement. DISK is the default device type.
are options that are specific to UNIX. You can use any of the options that are available in the FILENAME statement. See FILENAME Statement: UNIX for a description of the host options.
specifies the fileref that is assigned to the directory in which the external file resides.
Details |
FILENAME returns a 0 if the operation is successful, and a nonzero number if it was not successful.
If you use the FTP access method to communicate with a remote system, SAS might return the following error message:
ERROR: Physical file does not exist.
This error is likely to occur when the fully qualified data set name is specified within single quotation marks. For example:
FILENAME fileref FTP 'system.dataset.name' USER='username' PASS='password' HOST='ip_address';
By default, SAS appends the profile prefix to the beginning of the data set name. To prevent the profile prefix from being appended, enclose the data set name with both double and single quotation marks:
FILENAME fileref FTP "'external_file'" USER='username' PASS='password' HOST='ip_address';
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.