Previous Page | Next Page

Statements

FILENAME Statement, CATALOG Access Method



Enables you to reference a SAS catalog as an external file.
Valid: anywhere
Category: Data Access

Syntax
Arguments
Catalog Options
Details
Examples
Example 1: Using %INCLUDE with a Catalog Entry
Example 2: Using %INCLUDE with Several Entries in a Single Catalog
Example 3: Reading and Writing a CATAMS Entry
Example 4: Writing to a SOURCE Entry
Example 5: Executing an Autocall Macro from a SAS Catalog
See Also

Syntax

FILENAME fileref CATALOG 'catalog' <catalog-options>;


Arguments

fileref

is a valid fileref.

CATALOG

specifies the access method that enables you to reference a SAS catalog as an external file. You can then use any SAS commands, statements, or procedures that can access external files to access a SAS catalog.

Tip: This access method makes it possible for you to invoke an autocall macro directly from a SAS catalog.
Tip: With this access method you can read any type of catalog entry, but you can write only to entries of type LOG, OUTPUT, SOURCE, and CATAMS.
Tip: If you want to access an entire catalog (instead of a single entry), you must specify its two-level name in the catalog parameter.
Alias: LIBRARY
'catalog'

is a valid two-, three-, or four-part SAS catalog name, where the parts represent library.catalog.entry.entrytype.

Default: The default entry type is CATAMS.
Restriction: The CATAMS entry type is used only by the CATALOG access method. The CPORT and CIMPORT procedures do not support this entry type.

Catalog Options

Catalog-options can be any of the following:

LRECL=lrecl

where lrecl is the maximum record length for the data in bytes.

Default: For input, the actual LRECL value of the file is the default. For output, the default is 132.
Interaction: Alternatively, you can specify a global logical record length by using the LRECL= system option.
RECFM=recfm

where recfm is one of four record formats:

F

is fixed-record format. Data is transferred in image (binary) mode.

P

is print format.

S

is stream-record format. Data is transferred in image (binary) mode.

Interaction: The amount of data that is read is controlled by 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 LRECL.
See Also: The NBYTE= option in the INFILE statement.
V

is variable-record format (the default). In this format, records have varying lengths, and they are separated by newlines. Data is transferred in image (binary) mode.

Default: V
DESC=description

where description is a text description of the catalog.

MOD

specifies to append to the file.

Default: If you omit MOD, the file is replaced.

Details

The CATALOG access method in the FILENAME statement enables you to reference a SAS catalog as an external file. You can then use any SAS commands, statements, or procedures that can access external files to access a SAS catalog. As an example, the catalog access method makes it possible for you to invoke an autocall macro directly from a SAS catalog. See Executing an Autocall Macro from a SAS Catalog.

With the CATALOG access method you can read any type of catalog entry, but you can write to only entries of type LOG, OUTPUT, SOURCE, and CATAMS. If you want to access an entire catalog (instead of a single entry), you must specify its two-level name in the catalog argument.


Examples


Example 1: Using %INCLUDE with a Catalog Entry

This example submits the source program that is contained in SASUSER.PROFILE.SASINP.SOURCE:

filename fileref1 
         catalog 'sasuser.profile.sasinp.source';
%include fileref1;


Example 2: Using %INCLUDE with Several Entries in a Single Catalog

This example submits the source code from three entries in the catalog MYLIB.INCLUDE. When no entry type is specified, the default is CATAMS.

filename dir catalog 'mylib.include';
%include dir(mem1);
%include dir(mem2);
%include dir(mem3);


Example 3: Reading and Writing a CATAMS Entry

This example uses a DATA step to write data to a CATAMS entry, and another DATA step to read it back in:

filename mydata 
         catalog 'sasuser.data.update.catams';

   /* write data to catalog entry update.catams */
data _null_;
   file mydata;
   do i=1 to 10;
      put i;
   end;
run;

   /* read data from catalog entry update.catams */
data _null_;
   infile mydata;
   input;
   put _INFILE_;
run;


Example 4: Writing to a SOURCE Entry

This example writes code to a catalog SOURCE entry and then submits it for processing:

filename incit 
         catalog 'sasuser.profile.sasinp.source';

data _null_;
   file incit;
   put 'proc options; run;';
run;

%include incit;


Example 5: Executing an Autocall Macro from a SAS Catalog

If you store an autocall macro in a SOURCE entry in a SAS catalog, you can point to that entry and invoke the macro in a SAS job. Use these steps:

  1. Store the source code for the macro in a SOURCE entry in a SAS catalog. The name of the entry is the macro name.

  2. Use a LIBNAME statement to assign a libref to that SAS library.

  3. Use a FILENAME statement with the CATALOG specification to assign a fileref to the catalog: libref.catalog.

  4. Use the SASAUTOS= option and specify the fileref so that the system knows where to locate the macro. Also set MAUTOSOURCE to activate the autocall facility.

  5. Invoke the macro as usual: %macro-name.

This example points to a SAS catalog named MYSAS.MYCAT. It then invokes a macro named REPORTS, which is stored as a SAS catalog entry named MYSAS.MYCAT.REPORTS.SOURCE:

libname mysas 'SAS-library';
filename mymacros catalog 'mysas.mycat';
options sasautos=mymacros mautosource;

%reports


See Also

Statements:

FILENAME Statement

FILENAME Statement, EMAIL (SMTP) Access Method

FILENAME Statement, FTP Access Method

FILENAME Statement, SOCKET Access Method

FILENAME Statement, SFTP Access Method

FILENAME Statement, URL Access Method

Previous Page | Next Page | Top of Page