Previously complex, this operation is now simplified thanks to a specific type of library: the CAS-type Caslib (srcType="CAS").
The Concept: A Bridge Between Two Memories
Traditionally, a caslib points to a physical source (a system folder, an Oracle database, etc.) and loads data into memory.
The novelty here is to define a caslib whose source is not a disk, but the memory of another CAS server.
Imagine you need to migrate in-memory tables from a source environment (e.g., "From35") to a target environment (e.g., "Target"), located in two different namespaces.
Here is the 3-step procedure to perform this transfer cleanly:
On your target environment, you will create a special caslib. It will act as a tunnel to the source environment.
CAS transfersess;
PROC CAS;
/* Création de la caslib 'transfer' qui pointe vers la source */
table.addcaslib /
name="transfer",
dataSource={
srctype="CAS", /* Le type magique */
user="mon_user",
password="mon_password", /* À encoder de préférence ! */
cashost="controller.source-env-host", /* L'adresse du contrôleur source */
caslib="VAModels" /* La caslib source à lire */
};
QUIT;
1
CAS transfersess;
2
PROC CAS;
3
/* Création de la caslib 'transfer' qui pointe vers la source */
4
TABLE.addcaslib /
5
name="transfer",
6
dataSource={
7
srctype="CAS", /* Le type magique */
8
user="mon_user",
9
password="mon_password", /* À encoder de préférence ! */
10
cashost="controller.source-env-host", /* L'adresse du contrôleur source */
11
caslib="VAModels"/* La caslib source à lire */
12
};
13
QUIT;
Note: The cashost corresponds to the hostname of the source CAS controller (retrievable via the CAS configuration).
Step 2: Load the Data into the Target Memory
The tables from the source environment are now visible via the transfer library. You just need to load them into the memory of your final destination library (e.g., VAModels on the target).
PROC CAS;
/* Copie de la table de 'transfer' vers 'VAModels' locale */
table.loadtable /
caslib="transfer"
path="MA_TABLE_SOURCE"
casout={caslib="VAModels", name="MA_TABLE_CIBLE", promote=TRUE};
QUIT;
1
PROC CAS;
2
/* Copie de la table de 'transfer' vers 'VAModels' locale */
The data is now in the new server's memory, but it will disappear upon restart if it is not saved to the local disk of the new environment.
PROC CAS;
/* Écriture physique sur le disque de la cible */
table.save /
caslib="VAModels"
name="MA_TABLE_CIBLE"
table={caslib="VAModels", name="MA_TABLE_CIBLE"}
replace=True;
QUIT;
The codes and examples provided on WeAreCAS.eu are for educational purposes. It is imperative not to blindly copy-paste them into your production environments. The best approach is to understand the logic before applying it. We strongly recommend testing these scripts in a test environment (Sandbox/Dev). WeAreCAS accepts no responsibility for any impact or data loss on your systems.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.