CAS

Sharing data between two CAS sessions

Simon 30/04/2021 5 Aufrufe

In the SAS© Viya architecture, memory and session management is a key concept. It frequently happens that a user loads data or creates a library (caslib) in one session (let's call it Session A), and then wants to access it from a new session (Session B).

However, a direct attempt to assign the existing library in the new session often fails to show the expected data. Why does this partitioning exist and how can it be bypassed?

Illustration

Understanding Scope

The core of the problem lies in the scope of your caslib and the tables it contains. By default, when you create a caslib or load a table into memory without specific configuration, it often has a session scope (session scope).

  • Session Scope: The data is private. It "belongs" exclusively to the session that created it (Session A). Session B can neither see nor use it, even if you try to redefine the library.

  • Global Scope: The data is shared. It is accessible to all sessions that have sufficient rights to access the CAS server.

The Solution: Promotion

It is not possible to simply "connect" Session B to the private memory space of Session A. To make the data accessible to Session B (and others), you must change the status of your data.

The method is to use the promote action.

How to proceed?

Instead of trying to reassign the entire library, you must explicitly promote the specific tables you want to share.

  1. In Session A (owner): Use the promotion action on your table. This moves the table from the session's local memory to the server's global memory.

  2. In Session B: Once the table is in global scope, it becomes visible and accessible instantly, without needing to reload the data from disk.

If you don't see your tables from a new session, don't try to "fix" the library definition. Ask yourself about the scope of your data.

  • If the table is in session scope, it is invisible to others.

  • To share it, you must promote it to global scope.