FILENAME Statement, WebDAV Access Method

Enables you to access remote files by using the WebDAV protocol.
Valid in: Anywhere
Category: Data Access
Restriction: Access to WebDAV servers is not supported on Open VMS.

Syntax

Arguments

fileref
is a valid fileref.
Tip:The association between a fileref and an external file lasts only for the duration of the SAS session or until you change it or discontinue it with another FILENAME statement. You can change the fileref for a file as often as you want.
WEBDAV
specifies the access method that enables you to use WebDAV (Web Distributed Authoring and Versioning) to read from or write to a file from any host machine that you can connect to on a network with a WebDAV server running.
'external-file'
specifies the name of the file that you want to read from or write to a WebDAV server. The external file must be in one of these forms:
http://hostname/path-to-the-file
https://hostname/path-to-the-file
http://hostname:port/path-to-the-file
https://hostname:port/path-to-the-file
Requirement:When using the HTTPS communication protocol, you must use the SSL (Secure Sockets Layer) protocol that provides secure network communications. For more information, see Encryption in SAS.
Operating environment:For details about specifying the physical names of external files, see the SAS documentation for your operating environment.

WebDAV Options

webdav-options can be any of the following:

DEBUG
writes debugging information to the SAS log.
DIR
enables you to access directory files. Specify the directory name in the external-file argument. You must use valid directory syntax for the specified host.
Tip:See the FILEEXT option for information about specifying filename extensions.
ENCODING='encoding-value'
specifies the encoding to use when SAS is reading from or writing to an external file. The value for ENCODING= indicates that the external file has a different encoding from the current session encoding.
When you read data from an external file, SAS transcodes the data from the specified encoding to the session encoding. When you write data to an external file, SAS transcodes the data from the session encoding to the specified encoding.
Default:SAS assumes that an external file is in the same encoding as the session encoding.
See:Encoding Values in SAS Language Elements in SAS National Language Support (NLS): Reference Guide
FILEEXT
specifies that a file extension is automatically appended to the filename when you use the DIR option.
Interaction: The autocall macro facility always passes the extension .SAS to the file access method as the extension to use when opening files in the autocall library. The DATA step always passes the extension .DATA. If you define a fileref for an autocall macro library and the files in that library have a file extension of .SAS, use the FILEEXT option. If the files in that library do not have an extension, do not use the FILEEXT option. For example, if you define a fileref for an input file in the DATA step and the file X has an extension of .DATA, you would use the FILEEXT option to read the file X.DATA. If you use the INFILE or FILE statement, enclose the member name and extension in quotation marks to preserve case.
Tip:The FILEEXT option will be ignored if you specify a file extension in the FILE or INFILE statement.
LOCALCACHE=”directory name
specifies a directory where a temporary subdirectory is created to hold local copies of the server files. Each fileref has its own unique subdirectory. If a directory is not specified, then the subdirectories are created in the SAS Work directory. SAS deletes the temporary files when the SAS program completes.
Default:SAS Work directory
LOCKDURATION=n
specifies the number of minutes that the files that are written through the WebDAV fileref are locked. SAS unlocks the files when the SAS program successfully finishes executing. If the SAS program fails, then the locks expire after the time allotted.
Default:30 minutes
LOWCASE_MEMNAME
enables autocall macro retrieval of lowercase directory or member names from WebDAV servers.
Restriction:SAS autocall macro retrieval always searches for uppercase directory member names. Mixed-case directory or member names are not supported.
LRECL=lrecl
where lrecl is the logical record length of the data.
Default:256
Interaction:Alternatively, you can specify a global logical record length by using the LRECL= System Option in SAS System Options: Reference.
MOD
Places the file in Update mode and appends updates to the bottom of the file.
PASS='password'
where password is the password to use with the user name that is specified in the USER option. The password is case sensitive and it must be enclosed in single or double quotation marks.
Alias:PASSWORD=, PW=, PWD=
Tip:To use an encoded password, use the PWENCODE procedure in order to disguise the text string, and then enter the encoded password for the PASS= option. For more information, see PWENCODE Procedure in Base SAS Procedures Guide .
PROMPT
specifies to prompt for the user logon password, if necessary.
Interaction:TheUSER= and PASS= options override the PROMPT option if all three options are specified. If you specify the PROMPT option and do not specify the USER= or PASS= option, you will be prompted for a user ID and password.
PROXY=url
specifies the Uniform Resource Locator (URL) for the proxy server in one of these forms:
http://hostname/
http://hostname:port/
RECFM=recfm
where recfm is one of two record formats:
S
is stream-record format. Data is transferred in image (binary) mode.
Tip:The amount of data that is read is controlled by the current LRECL value or the value of the NBYTE= variable in the INFILE statement. The NBYTE= option specifies a variable that is equal to the amount of data to be read. This amount must be less than or equal to the LRECL. To avoid problems when you transfer large binary files such as PDF or GIF, set NBYTE=1 to transfer one byte at a time.
See:The NBYTE= option in the INFILE statement.
V
is variable-record format (the default). In this format, records have varying lengths, and they are transferred in text (stream) mode.
Tip:Any record larger than LRECL is truncated.
Default:V
USER='username'
where username is used to log on to the URL server. The user ID is case sensitive and it must be enclosed in single or double quotation marks.
Alias:UID=

Details

When you access a WebDAV server to update a file, the file is pulled from the WebDAV server to your local disk storage for processing. When this processing is complete, the file is pushed back to the WebDAV server for storage. The file is removed from the local disk storage when it is pushed back.
The Secure Sockets Layer (SSL) protocol is used when the URL begins with “https” instead of “http”. The SSL protocol provides network security and privacy. Developed by Netscape Communications, SSL uses encryption algorithms that include RC2, RC4, DES, tripleDES, IDEA, and MD5. Not limited to providing only encryption services, SSL can also perform client and server authentication and use message authentication codes. SSL is supported by both Netscape Navigator and Internet Explorer. Many Web sites use the protocol to provide confidential user information such as credit card numbers. The SSL protocol is application independent, which enables protocols such as HTTP, FTP, and Telnet to be layered transparently above it. SSL is optimized for HTTP.
Note: WebDAV servers have defined levels of permissions at both the directory and file level. The WebDAV access method honors those permissions. For example, if a file is available as read-only, the user will not be able to modify it.
Operating Environment Information: Using the FILENAME statement requires information that is specific to your operating environment. The WebDAV access method is fully documented here, but for more information about how to specify filenames, see the SAS documentation for your operating environment.

Examples

Example 1: Accessing a File at a Web Site

This example accesses the file rawFile.txt at site www.mycompany.com.
filename foo webdav 'https://www.mycompany.com/production/files/rawFile.txt'
   user='wong' pass='jd75ld';
data _null_;
   infile foo;
   input a $80.;
run;

Example 2: Using a Proxy Server

This example accesses the file acctgfile.dat by using the proxy server otherwebsvr:80.
filename foo webdav 'https://webserver.com/webdav/acctgfile.dat' 
   user='sanchez' pass='239sk349exz'
   proxy='http://otherwebsvr.com:80';
data _null_;
   infile foo;
   input a $80.;
run;

Example 3: Writing to a New Member of a Directory

This example writes the file SHOES to the directory TESTING.
filename writeit webdav
   "https://webserver.com:8443/webdav/testing/"
    dir user="webuser" pass=XXXXXXXXX;
    data _null_;
       file writeit(shoes);
       set sashelp.shoes;
       put region $25. product $14.;
    run;

Example 4: Reading from a Member of a Directory

This example reads the file SHOES from the directory TESTING1.
filename readit webdav
   "https://webserver.com:8443/webdav/testing1/"
   dir user="webuser" pass=XXXXXXXXX;
   data shoes;
      length region $25  product $14;
      infile readit(shoes);
      input region $25. product $14.;
   run;

Example 5: Using a WebDAV Location as an Autocall Macro Library

By default, the autocall macro facility expects uppercase filenames. This example accesses the file MYTEST in the autocall macro library WRITEIT.
filename writeit webdav
   "https://webserver.com/webdav/macrolib"
      dir fileext user="webuser" pass=XXXXXXXXX;
options SASAUTOS=(writeit);
/* expects a file called MYTEST.SAS */
%MYTEST;

Example 6: Accessing a Lowercased Autocall Macro Member

The following example accesses the file testmem.sas in the autocall macro library LIST. The LOWCASE_MEMNAME option is used to access the file, which is in lowercase.
filename list webdav "https://t1234.na.fyi.com:8443/accounting/"
   dir fileext user="xxxxx" pass="xxxxx" LOWCASE_MEMNAME;
options sasautos=(list);
%testmem;

Example 7: Using a %INCLUDE Statement and Macro Invocation to Access a Lowercased Autocall Macro Member

The following example accesses the file testmem.sas in the autocall macro library MYTEST. Because the file is accessed by using the %INCLUDE statement, case sensitivity is preserved.
filename mytest webdav "https://t1234.na.fyi.com:8443/payroll/"
   dir user="xxxxxx" pass="xxxxx";
%include mytest(testmem.sas) /source2;
%testmem;
If the filename was in uppercase, the reference to the filename in the %INCLUDE statement and macro call needs to be uppercase.
%include mytest(TESTMEM.SAS) /source2;
%TESTMEM;

Example 8: Accessing a File with a Mixed-Case Name

The following example accesses the file fileNOext from the production directory. Because the file is quoted in the INFILE statement, case sensitivity is preserved and the file extension is ignored.
filename test webdav "https://t1234.na.fyi.com:8443/production"
     dir user="xxxxxx" pass="xxxxx";
data _null_;
   infile test('fileNOext');
   input;
   list;
run;

Example 9: Using the FILEEXT Option to Automatically Attach a File Extension

The following example accesses the file testmem.sas from the sales directory. The FILEEXT option automatically adds .DATA as the file extension. The member name that is read is testmem.DATA.
filename listing webdav "https://t1234.na.fyi.com:8443/sales"
     dir fileext user="xxxxxx" pass="xxxxx";
data _null_;
   infile listing(testmem);
   input;
   list;
run;