Previous Page | Next Page

Allocating External Files

Ways of Allocating External Files


Overview of Allocating External Files

To work with an external file in SAS software, you must first allocate the file. File allocation is the process of identifying an external file to SAS software. If you are allocating a new data set, such as a sequential file, partitioned data set (PDS), or partitioned data set extended (PDSE), you must specify that it is new and you must describe its structure and format. These actions are not required for new files in the UNIX System Services (USS) file system.

The method you use to allocate an external file depends on whether you plan to use the file more than once in your SAS program. See Allocating a File for a Single Use and Allocating a File for Multiple Uses.


Allocating a File for a Single Use

If you plan to use an existing external file only once in your SAS program, then you can allocate it by specifying the physical filename in a SAS statement or command. For example, this INCLUDE command allocates an existing sequential data set and includes it into the PROGRAM EDITOR window:

include 'myid.report.data'

Similarly, this PROC PRINTTO statement allocates a new PDS member:

proc printto print='userid.output.data(rockport)' new;


Allocating a File for Multiple Uses

If you plan to use the same external file several times in your SAS program, then use one of the following methods to allocate the file:

SAS FILENAME statement or function

You can use these methods in all modes for most types of files. See Using the FILENAME Statement or Function to Allocate External Files or FILENAME Function: z/OS for more information.

JCL DD statement

You can use this method if you use z/OS in batch mode. See Using the JCL DD Statement to Allocate External Files for more information.

Note:   Unlike the other two methods, if you use the JCL DD statement to allocate a file, there is no way to deallocate the file until the job ends.  [cautionend]

TSO ALLOCATE command

You can use this method if you use TSO under z/OS. See Using the TSO Allocate Command to Allocate External Files for more information.

Each of these methods establishes a fileref or a ddname that you can subsequently use to refer to the file instead of specifying the data set name again. See Referring to External Files for more information.

Previous Page | Next Page | Top of Page