Chapter Contents

Previous

Next
FILENAME, URL Access Method

FILENAME, URL Access Method



Allows you to access remote files using the URL access method

Valid: anywhere
Category: Data Access


Syntax
Arguments
Details
Examples
Example 1: Accessing a File at a Web Site
Example 2: Specifying a User Id and a Password
Example 3: Reading the First 15 Records from a URL File
See Also

Syntax

FILENAME fileref URL 'external-file'
<url-options>;

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.

URL
specifies the access method that enables you to read a file from any host machine that you can connect to on a network with a URL server running.
Alias: HTTP

'external-file'
specifies the name of the file you want to read from on a URL server. The access method must be in one of these forms
http://hostname/file
http://hostname:portno/file

Operating Environment Information:   For details on specifying the physical names of external files, see the SAS documentation for your operating environment.  [cautionend]

url-options
can be any of the following:

BLOCKSIZE=blocksize
where blocksize is the size of the URL data buffer in bytes.
Default: 8K

DEBUG
writes debugging information to the SAS log.
Tip: The result of the HELP command is returned as records.

LRECL=lrecl
where lrecl is the logical record length.
Default: 256

PASS='password'
where password is the password to use with the user name that is specified in the USER option.
Tip: You can specify the PROMPT option instead of the PASS option, which tells the system to prompt you for the password.

PROMPT
specifies to prompt for the user login password if necessary.
Tip: If you specify PROMPT, you do not need to specify PASS=.

PROXY=url
specifies the universal resource locator (URL) for the proxy server in one of these forms:
http://hostname/
http://hostname:portno/

RECFM=recfm
where recfm is one of three record formats:
F is fixed record format. Thus, all records are of size LRECL with no line delimiters. Data are transferred in image (binary) mode.
S is stream record format. Data are 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 FILE or INFILE statement. The NBYTE= option specifies a variable equal to the amount of data to be read. This amount must be less than or equal to LRECL.
See Also: The NBYTE= option in the FILE statement and 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 in to the URL server.
Tip: If you specify user='*', then the user is prompted for an id.
Interaction: If PROMPT is specified, but USER= is not, the user is prompted for an id as well as a password.


Details

Operating Environment Information:   Using the FILENAME statement requires information specific to your operating environment. The URL access method is fully documented here, but for more information on how to specify file names, see the SAS documentation for your operating environment.  [cautionend]


Examples


Example 1: Accessing a File at a Web Site

This example accesses document test.dat at site www.a.com:

filename foo url 'http://www.a.com/test.dat'
         proxy='http://www.gt.sas.com';

Example 2: Specifying a User Id and a Password

This example accesses document file1.html at site www.b.com and requires a user id and password:

filename foo url 'http://www.b.com/file1.html'
         user='jones' prompt;

Example 3: Reading the First 15 Records from a URL File

This example reads the first 15 records from a URL file and writes them to the SAS log with a PUT statement:

filename foo url 
    'http://www.sas.com/service/techsup/intro.html';
       
data _null_;
   infile foo length=len;
   input record $varying200. len;
   put record $varying200. len;
   if _n_=15 the stop;
run;

See Also

Statements:

FILENAME
FILENAME, CATALOG Access Method
FILENAME, FTP Access Method
FILENAME, SOCKET Access Method


Chapter Contents

Previous

Next

Top of Page

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