SAS Mainframe

SAS on Mainframe: What to Do When the WORK Library is Full?

Simon 21/04/2009 8 vistas

The error "File is full and may be damaged" is a classic dreaded by SAS© users, especially when extracting large volumes of data (like DB2 tables).

On a PC (Windows), this usually means your hard drive is full. But on a Mainframe (z/OS), the logic is more subtle: the disk isn't necessarily full, but you have exceeded the space that was allocated to you.

Here's how to understand and solve this space allocation problem, based on advice from forum experts.

1. Diagnosis: Space Allocation on Mainframe

Unlike Windows where a file grows as long as there is space, the Mainframe requires that space be defined in advance (pre-allocated) via Extents.

The system works in two stages:

  1. Primary Allocation: A large block of space reserved at the start of the job.

  2. Secondary Allocations: Small additional blocks that the system fetches if the primary block is full (usually limited to 15 or 16 extensions).

The error ERROR: Write to WORK.A.DATA failed. File is full means that SAS© has filled the primary allocation AND all allowed secondary allocations.

2. Solution 1: Compression (The Immediate Reflex)

Before asking the administration for more disk space, try to reduce the size of your data. The expert David suggests enabling binary compression. On large data with text or repetitions, this can reduce the size by 50% to 80%.

SAS© Code:

1/* Compression activée pour cette table spécifique */
2DATA WORK.A (compress=yes);
3 SET DB2.GRANDE_TABLE;
4RUN;
5 
6/* OU activée globalement pour toute la session */
7options compress=yes;
Note: This slightly increases CPU usage, but significantly reduces I/O (Input/Output), which is often beneficial on Mainframe.

3. Solution 2: Modify JCL Parameters (WORK)

If compression is not enough, you must request more space when the job starts. On Mainframe, SAS© is launched via a JCL script (EXEC SAS©...). You can pass a WORK parameter to redefine the allocation sizes.

Typical JCL Syntax (Batch):

1//MONJOB EXEC SAS913,WORK='500 200'
  • 500: Size of the Primary allocation (in cylinders or tracks depending on the site configuration).

  • 200: Size of the Secondary allocation.

The expert's calculation: David recommends a "90/10" strategy:

  • Estimate the final total size.

  • Allocate 90% of this size as Primary.

  • Allocate 10% as Secondary.

This avoids fragmentation and reduces the risk of late failure if the disk is physically fragmented.

4. Solution 3: The Heavy Artillery (Spanning Volumes)

Sometimes, a single physical disk (DASD volume) is not enough to hold your temporary table, even using all the available space (about 4300 cylinders on the old 3390 models).

The expert Chuck explains how to extend the WORK library across multiple physical volumes. This requires modifying the JCL to concatenate several disk allocations.

Advanced JCL Example:

1//WORK DD DSN=&&WORK,SPACE=(CYL,(4300,100)),UNIT=SASDS,VOL=SER=VOL01
2// DD DSN=&&WORK,SPACE=(CYL,(4300,100)),UNIT=SASDS,VOL=SER=VOL02
3// DD DSN=&&WORK,SPACE=(CYL,(4300,100)),UNIT=SASDS,VOL=SER=VOL03
Note: This technique is reserved for advanced users who have access to detailed JCL configuration.

If you encounter the "File Full" error on Mainframe:

  1. Compress (COMPRESS=YES): It's simple and often sufficient.

  2. Increase the allocation (WORK='Prim Sec'): Request more cylinders in your JCL.

  3. Check the SMS: Sometimes, the storage class (Storage Management Subsystem) automatically limits file sizes. In this case, you'll need to contact the system administrator.

Referencias y Documentos