Published on :
Data Quality CREATION_INTERNE

PROC DMSRVPROCESSSVC

This code is also available in: Deutsch Español Français
Awaiting validation
This example executes a processing service on a DataFlux Data Management server installed on the default port. The TIMEOUT option specifies that the processing service will terminate after 360 seconds if it does not complete within this period. The processing service is executed under the credentials specified in the procedure. The processing service must have been previously created and uploaded to the DataFlux Data Management server.
Data Analysis

Type : CREATION_INTERNE


The examples use generated data (datalines) for scenarios where interaction with SAS data is to be demonstrated, even if the procedure itself calls an external service.

1 Code Block
PROC DMSRVPROCESSSVC
Explanation :
This example shows the simplest execution of a DataFlux processing service. It specifies the host (localhost by default) and port of the Data Management server, as well as the name of the service file (.djf) to execute.
Copied!
1PROC DMSRVPROCESSSVC
2 HOST='http://localhost'
3 PORT=21036
4 SERVICE='mon_service_basique.djf';
5RUN;
2 Code Block
PROC DMSRVPROCESSSVC
Explanation :
This example extends the use of the procedure by including authentication information (USERID and PASSWORD). This is a common scenario for services requiring secure access. HOST and SERVICE values here are examples.
Copied!
1PROC DMSRVPROCESSSVC
2 HOST='http://prod.dmserver.com'
3 PORT=21036
4 SERVICE='nettoyage_donnees_client.djf'
5 USERID='sasuser'
6 PASSWORD='mypassword123';
7RUN;
3 Code Block
PROC DMSRVPROCESSSVC Data
Explanation :
This example illustrates the use of the TIMEOUT option, crucial for long-running processing services. A short timeout is defined to simulate a scenario where the service does not respond in time. The SAS code also includes a DATA _NULL_ step to check the automatic macro variable &SYSINFO. to detect if the procedure encountered an error, such as a timeout, allowing for programmatic error handling.
Copied!
1/* Préparation de données factices si le service devait les consommer */
2DATA work.raw_data;
3 INPUT ID $ Name $;
4 DATALINES;
5101 Alice
6102 Bob
7103 Charlie
8;
9RUN;
10 
11%let service_name = 'analyse_transactions_longues.djf';
12%let server_host = 'http://dm.dev.internal.com';
13%let server_port = 21036;
14%let user_id = 'admin_user';
15%let user_pw = 'secure_pw';
16 
17PROC DMSRVPROCESSSVC
18 HOST=&server_host.
19 PORT=&server_port.
20 SERVICE=&service_name.
21 TIMEOUT=10 /* Définit un timeout court de 10 secondes pour simuler une défaillance ou un processus trop long */
22 USERID=&user_id.
23 PASSWORD=&user_pw.;
24RUN;
25 
26/* Vérification du code de retour pour la gestion des erreurs */
27DATA _NULL_;
28 IF &SYSINFO. NE 0 THEN DO;
29 PUT 'AVERTISSEMENT: Le service de traitement &service_name. sur &server_host. a expiré ou a échoué. Code SYSINFO: ' &SYSINFO.;
30 /* Des actions spécifiques peuvent être ajoutées ici, comme l'envoi d'une alerte */
31 END;
32 ELSE DO;
33 PUT 'INFO: Le service de traitement &service_name. s''est terminé avec succès.';
34 END;
35RUN;
4 Code Block
PROC DMSRVPROCESSSVC Data
Explanation :
This advanced example illustrates how the DMSRVPROCESSSVC procedure can be integrated into a SAS Viya workflow using macro variables to dynamically set execution parameters. Based on an environment variable (e.g., 'PRODUCTION' or 'DEVELOPMENT'), the DataFlux host, port, and service name are adjusted. This simulates necessary flexibility in complex deployments. Although the procedure does not directly execute CAS code, it would be part of a pipeline where data could be prepared in CAS before being processed by the DataFlux service, or results could be reloaded into CAS.
Copied!
1/* Simulation de paramètres dynamiques qui pourraient être passés dans un environnement Viya/CAS */
2%let environnement = 'PRODUCTION'; /* Peut être 'DEVELOPPEMENT', 'PRODUCTION' */
3%let service_base_name = 'validation_adresse';
4 
5/* Logique conditionnelle pour déterminer l'hôte/port/service en fonction de l'environnement */
6%IF "&environnement." = "PRODUCTION" %THEN %DO;
7 %let dm_host = 'http://prod.dmserver.sas.com';
8 %let dm_port = 21040;
9 %let service_to_run = "&service_base_name._prod.djf";
10%END;
11%ELSE %DO;
12 %let dm_host = 'http://dev.dmserver.sas.com';
13 %let dm_port = 21036;
14 %let service_to_run = "&service_base_name._dev.djf";
15%END;
16 
17/* Création de données SAS d'entrée pour le service (le service DataFlux y accéderait via une bibliothèque ou un fichier partagé) */
18DATA work.adresses_a_verifier;
19 INPUT ClientID $ Adresse $ CodePostal $;
20 DATALINES;
21C001 "10 Rue de la Paix" 75001
22C002 "25 Avenue des Champs" 75008
23;
24RUN;
25 
26/* Exécution du service de traitement avec les paramètres dynamiques */
27PROC DMSRVPROCESSSVC
28 HOST=&dm_host.
29 PORT=&dm_port.
30 SERVICE=&service_to_run.
31 USERID='viya_svc_user'
32 PASSWORD='viya_svc_password_secure';
33RUN;
34 
35/* Note : La procédure DMSRVPROCESSSVC elle-même n'est pas une procédure CAS.
36 C'est l'environnement SAS Viya qui permet de gérer et de déclencher de telles procédures
37 et de passer des paramètres de manière dynamique, potentiellement après des traitements CAS. */
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.