Published on :
Troubleshooting CREATION_INTERNE

Troubleshooting CAS LIBNAME Engine Errors

This code is also available in: Deutsch Español Français
Awaiting validation
The error 'The call to Cloud Analytic Services failed' is typically caused by a procedure or DATA step attempting to create multiple output tables using the same CAS libref for both input and output. The CAS LIBNAME engine cannot process multiple output actions simultaneously on a single libref. This is particularly noticeable when the WRITETRANSFERSIZE option is set to a small value, exacerbating contention. Proposed solutions include using separate DATA or PROC steps for each output table, or using a different data engine for creating intermediate or final tables.
Data Analysis

Type : CREATION_INTERNE


Examples use generated data (SASHELP.CARS) or datalines to ensure code autonomy.

1 Code Block
DATA STEP Data
Explanation :
This example demonstrates the exact scenario that causes the error described in the documentation. A single DATA step attempts to write two tables ('one' and 'two') simultaneously to the same CAS libref ('mycas'). The CAS LIBNAME engine, especially with an artificially small 'writetransfersize', cannot handle multiple concurrent output streams in this manner, leading to the failure of the call to Cloud Analytic Services. The `writetransfersize=1k` option is used to make the error more likely in a test environment.
Copied!
1/* Établit une connexion CAS avec une petite taille de transfert pour provoquer l'erreur */
2LIBNAME mycas cas s_port=10000 s_host='localhost' caslib='casuser' s_caslib='casuser' s_nthreads=1 s_timeout=1000 writetransfersize=1k;
3 
4/* Crée deux tables de sortie dans CAS en utilisant un seul DATA step */
5/* Ceci est le scénario qui génère l'erreur 'The call to Cloud Analytic Services failed' */
6DATA mycas.one mycas.two;
7 SET sashelp.cars;
8RUN;
9 
10/* Pour nettoyer après l'erreur (si la session n'est pas bloquée) */
11/* proc casutil incaslib='casuser'; droptable 'one'; droptable 'two'; run; */
12/* libname mycas clear; */
2 Code Block
DATA STEP Data
Explanation :
This example illustrates the simplest solution to the previous problem: dividing the creation of output tables into multiple sequential DATA steps. Each DATA step writes a single table to the CAS libref, thereby avoiding simultaneous access conflict and allowing the CAS LIBNAME engine to process requests individually. This approach is recommended for its clarity and adherence to best practices.
Copied!
1/* Établit une connexion CAS */
2LIBNAME mycas cas s_port=10000 s_host='localhost' caslib='casuser' s_caslib='casuser';
3 
4/* Crée la première table de sortie dans un DATA step distinct */
5DATA mycas.one;
6 SET sashelp.cars;
7RUN;
8 
9/* Crée la deuxième table de sortie dans un DATA step distinct */
10DATA mycas.two;
11 SET sashelp.cars;
12RUN;
13 
14/* Vérification des tables créées */
15PROC CASUTIL incaslib='casuser'; list tables; RUN;
16 
17/* Nettoyage */
18PROC CASUTIL incaslib='casuser'; droptable 'one'; droptable 'two'; RUN;
19LIBNAME mycas clear;
3 Code Block
PROC COPY Data
Explanation :
This advanced solution uses the PROC COPY procedure to transfer multiple tables from a temporary SAS library (WORK) to the CAS libref. PROC COPY internally manages the sequential transfer of tables, thus avoiding the contention issue observed with direct writing of multiple tables in a single DATA step. This is an efficient method to consolidate data transfer while respecting the constraints of the CAS LIBNAME engine.
Copied!
1/* Établit une connexion CAS */
2LIBNAME mycas cas s_port=10000 s_host='localhost' caslib='casuser' s_caslib='casuser';
3 
4/* Crée des données temporaires dans work */
5DATA work.temp_one;
6 SET sashelp.cars;
7 where make = 'Audi';
8RUN;
9 
10DATA work.temp_two;
11 SET sashelp.cars;
12 where make = 'BMW';
13RUN;
14 
15/* Utilise PROC COPY pour transférer séquentiellement les tables vers CAS */
16/* Cela est géré en interne par SAS pour éviter les conflits */
17PROC COPY in=work out=mycas;
18 select temp_one temp_two;
19RUN;
20 
21/* Vérification des tables créées */
22PROC CASUTIL incaslib='casuser'; list tables; RUN;
23 
24/* Nettoyage */
25PROC CASUTIL incaslib='casuser'; droptable 'temp_one' 'temp_two'; RUN;
26LIBNAME mycas clear;
27LIBNAME work clear;
4 Code Block
DATA STEP Data
Explanation :
This example focuses on better managing large data transfers to CAS by using the `WRITETRANSFERSIZE` option. Rather than a small value that can exacerbate performance or concurrency issues, a higher value (here 1M for 1 MB) is used to optimize the transfer. Although Example 1 showed how a small value could cause errors in specific scenarios, an appropriate value for `WRITETRANSFERSIZE` is crucial for the efficiency of CAS operations, especially for massive data ingestion. This example creates a single large table to illustrate the performance of optimized transfer.
Copied!
1/* Établit une connexion CAS avec une taille de transfert optimisée */
2/* Utiliser une valeur plus grande pour WRITETRANSFERSIZE */
3LIBNAME mycas cas s_port=10000 s_host='localhost' caslib='casuser' s_caslib='casuser' writetransfersize=1m;
4 
5/* Crée une table de grande taille dans CAS */
6DATA mycas.large_table;
7 DO _n_ = 1 to 100000;
8 var1 = ranuni(0);
9 var2 = rand('NORMAL');
10 OUTPUT;
11 END;
12RUN;
13 
14/* Vérification de la table créée */
15PROC CASUTIL incaslib='casuser'; list tables; RUN;
16PROC PRINT DATA=mycas.large_table(obs=5); RUN;
17 
18/* Nettoyage */
19PROC CASUTIL incaslib='casuser'; droptable 'large_table'; RUN;
20LIBNAME mycas clear;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.