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!
/* Établit une connexion CAS avec une petite taille de transfert pour provoquer l'erreur */
libname mycas cas s_port=10000 s_host='localhost' caslib='casuser' s_caslib='casuser' s_nthreads=1 s_timeout=1000 writetransfersize=1k;
/* Crée deux tables de sortie dans CAS en utilisant un seul DATA step */
/* Ceci est le scénario qui génère l'erreur 'The call to Cloud Analytic Services failed' */
data mycas.one mycas.two;
set sashelp.cars;
run;
/* Pour nettoyer après l'erreur (si la session n'est pas bloquée) */
/* proc casutil incaslib='casuser'; droptable 'one'; droptable 'two'; run; */
/* libname mycas clear; */
1
/* Établit une connexion CAS avec une petite taille de transfert pour provoquer l'erreur */
2
LIBNAME 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' */
6
DATA mycas.one mycas.two;
7
SET sashelp.cars;
8
RUN;
9
10
/* Pour nettoyer après l'erreur (si la session n'est pas bloquée) */
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!
/* Établit une connexion CAS */
libname mycas cas s_port=10000 s_host='localhost' caslib='casuser' s_caslib='casuser';
/* Crée la première table de sortie dans un DATA step distinct */
data mycas.one;
set sashelp.cars;
run;
/* Crée la deuxième table de sortie dans un DATA step distinct */
data mycas.two;
set sashelp.cars;
run;
/* Vérification des tables créées */
proc casutil incaslib='casuser'; list tables; run;
/* Nettoyage */
proc casutil incaslib='casuser'; droptable 'one'; droptable 'two'; run;
libname mycas clear;
1
/* Établit une connexion CAS */
2
LIBNAME 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 */
5
DATA mycas.one;
6
SET sashelp.cars;
7
RUN;
8
9
/* Crée la deuxième table de sortie dans un DATA step distinct */
10
DATA mycas.two;
11
SET sashelp.cars;
12
RUN;
13
14
/* Vérification des tables créées */
15
PROC CASUTIL incaslib='casuser'; list tables; RUN;
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!
/* Établit une connexion CAS */
libname mycas cas s_port=10000 s_host='localhost' caslib='casuser' s_caslib='casuser';
/* Crée des données temporaires dans work */
data work.temp_one;
set sashelp.cars;
where make = 'Audi';
run;
data work.temp_two;
set sashelp.cars;
where make = 'BMW';
run;
/* Utilise PROC COPY pour transférer séquentiellement les tables vers CAS */
/* Cela est géré en interne par SAS pour éviter les conflits */
proc copy in=work out=mycas;
select temp_one temp_two;
run;
/* Vérification des tables créées */
proc casutil incaslib='casuser'; list tables; run;
/* Nettoyage */
proc casutil incaslib='casuser'; droptable 'temp_one' 'temp_two'; run;
libname mycas clear;
libname work clear;
1
/* Établit une connexion CAS */
2
LIBNAME mycas cas s_port=10000 s_host='localhost' caslib='casuser' s_caslib='casuser';
3
4
/* Crée des données temporaires dans work */
5
DATA work.temp_one;
6
SET sashelp.cars;
7
where make = 'Audi';
8
RUN;
9
10
DATA work.temp_two;
11
SET sashelp.cars;
12
where make = 'BMW';
13
RUN;
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 */
17
PROC COPY in=work out=mycas;
18
select temp_one temp_two;
19
RUN;
20
21
/* Vérification des tables créées */
22
PROC CASUTIL incaslib='casuser'; list tables; RUN;
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!
/* Établit une connexion CAS avec une taille de transfert optimisée */
/* Utiliser une valeur plus grande pour WRITETRANSFERSIZE */
libname mycas cas s_port=10000 s_host='localhost' caslib='casuser' s_caslib='casuser' writetransfersize=1m;
/* Crée une table de grande taille dans CAS */
data mycas.large_table;
do _n_ = 1 to 100000;
var1 = ranuni(0);
var2 = rand('NORMAL');
output;
end;
run;
/* Vérification de la table créée */
proc casutil incaslib='casuser'; list tables; run;
proc print data=mycas.large_table(obs=5); run;
/* Nettoyage */
proc casutil incaslib='casuser'; droptable 'large_table'; run;
libname mycas clear;
1
/* Établit une connexion CAS avec une taille de transfert optimisée */
2
/* Utiliser une valeur plus grande pour WRITETRANSFERSIZE */
3
LIBNAME 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 */
6
DATA mycas.large_table;
7
DO _n_ = 1 to 100000;
8
var1 = ranuni(0);
9
var2 = rand('NORMAL');
10
OUTPUT;
11
END;
12
RUN;
13
14
/* Vérification de la table créée */
15
PROC CASUTIL incaslib='casuser'; list tables; RUN;
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.
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.