Published on :
Data Quality CREATION_INTERNE

Execute a DataFlux Data Management Studio Service (PROC DMSRVDATASVC)

This code is also available in: Deutsch Español Français
Awaiting validation
This procedure is used to interact with data quality services created and deployed via DataFlux Data Management Studio. It allows sending a SAS© dataset as input to a service, having the service executed on the DataFlux Data Management server, and then retrieving the results in a new SAS© dataset. Key options include specifying the SERVICE to execute, the input dataset (DATA=), and the output dataset (OUT=). The communication port defaults to 21036 if not specified.
Data Analysis

Type : CREATION_INTERNE


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

1 Code Block
PROC DMSRVDATASVC Data
Explanation :
This example illustrates the simplest use of the DMSRVDATASVC procedure. It creates an input dataset `work.insrv` with names and addresses. Then, it executes a service named 'StandardizeAddresses' (which must exist on the DataFlux server) using this dataset as input and stores the results in `work.outsrv_basic`. Finally, it displays the output dataset.
Copied!
1DATA work.insrv;
2 LENGTH Name $30 Address $50;
3 INPUT Name $ Address $;
4 DATALINES;
5 John Doe 123 Main St
6 Jane Smith 456 Oak Ave
7 ;
8RUN;
9 
10PROC DMSRVDATASVC
11 SERVICE='StandardizeAddresses'
12 DATA=work.insrv
13 OUT=work.outsrv_basic;
14RUN;
15 
16PROC PRINT DATA=work.outsrv_basic;
17 TITLE 'Results of the basic standardization service';
18RUN;
2 Code Block
PROC DMSRVDATASVC Data
Explanation :
This example shows how to specify additional options when executing a service. In addition to `SERVICE`, `DATA`, and `OUT`, it uses `SERVER` to explicitly designate the DataFlux server (here 'localhost') and `PORT` for a non-standard port (21037). The `LOG` option is added to capture service error or information messages in a SAS dataset.
Copied!
1DATA work.input_data;
2 LENGTH Email $50;
3 INPUT Email $;
4 DATALINES;
5 test @example.com
6 invalid-email
7 another.one @domain.co.uk
8 ;
9RUN;
10 
11PROC DMSRVDATASVC
12 SERVICE='EmailValidationService'
13 SERVER='localhost'
14 PORT=21037
15 DATA=work.input_data
16 OUT=work.output_data_intermediate
17 LOG=work.service_log;
18RUN;
19 
20PROC PRINT DATA=work.output_data_intermediate;
21 TITLE 'Results of the email validation service';
22RUN;
23 
24PROC PRINT DATA=work.service_log;
25 TITLE 'Service execution log';
26RUN;
3 Code Block
PROC DMSRVDATASVC Data
Explanation :
This advanced example simulates batch processing of customer names using a standardization service. The `ERRORONFAILURE=YES` option is crucial here: it instructs SAS to generate an error if the DataFlux service fails, which is useful for integration into automated processing chains. The code includes a simple macro to check the success of the operation via the dataset open return code, programmatically signaling errors.
Copied!
1DATA work.customer_names;
2 LENGTH CustomerID 8 FirstName $20 LastName $20;
3 INPUT CustomerID FirstName $ LastName $;
4 DATALINES;
5 1 John Doe
6 2 Jane Smith
7 3 PETER J. JONES
8 4 mary_ann
9 ;
10RUN;
11 
12PROC DMSRVDATASVC
13 SERVICE='NameStandardizationBatch'
14 DATA=work.customer_names
15 OUT=work.standardized_names
16 ERRORONFAILURE=YES;
17RUN;
18 
19/* Vérifier les erreurs potentielles dans le log */
20%MACRO CheckLog;
21 %LOCAL rc;
22 %LET rc = %SYSFUNC(OPEN(WORK.standardized_names, I));
23 %IF &rc EQ 0 %THEN %DO;
24 %PUT NOTE: The service executed successfully.;
25 %LET rc = %SYSFUNC(CLOSE(&rc));
26 %END;
27 %ELSE %DO;
28 %PUT ERROR: The service failed. Check the SAS log for more details.;
29 %END;
30%MEND CheckLog;
31 
32%CheckLog;
33 
34PROC PRINT DATA=work.standardized_names;
35 TITLE 'Standardized Customer Names';
36RUN;
4 Code Block
PROC DMSRVDATASVC Data
Explanation :
This example demonstrates the integration of the DMSRVDATASVC procedure into a SAS Viya environment with CAS tables. It initializes a CAS session and creates a CAS table (`mycas.raw_products`). The DMSRVDATASVC procedure is then called, specifying this CAS table as input. The data quality service (here 'ProductDescriptionCleanse') processes the table in distributed memory, and the results are stored in a new CAS table (`mycas.cleaned_products`). PROC CASUTIL and PROC PRINT commands are used to verify the CAS tables and display the processed data, highlighting in-memory processing.
Copied!
1CAS;
2CASLIB _ALL_ ASSIGN;
3 
4DATA _NULL_;
5 CALL SYMPUTX('CAS_SESSION_NAME', %SYSFUNC(GETOPTION(CASAUTOSESS)));
6RUN;
7 
8/* Création d'une table CAS à partir de données SAS */
9DATA mycas.raw_products;
10 LENGTH ProductID $10 Description $100;
11 INPUT ProductID $ Description $;
12 DATALINES;
13 P001 Hand Sanitizer 500ml
14 P002 Hand sanitizer 100ml
15 P003 Hand SANITIZER 200 ml
16 ;
17RUN;
18 
19/* Exécution du service Data Quality sur la table CAS */
20PROC DMSRVDATASVC
21 SERVICE='ProductDescriptionCleanse'
22 DATA=mycas.raw_products
23 OUT=mycas.cleaned_products;
24RUN;
25 
26/* Affichage des résultats de la table CAS */
27PROC CASUTIL SESSREF=&CAS_SESSION_NAME;
28 LIST TABLES / CASLIB='CASUSER';
29QUIT;
30 
31PROC PRINT DATA=mycas.cleaned_products;
32 TITLE 'Product Descriptions Cleaned via CAS';
33RUN;
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.
Copyright Info : Copyright © SAS Institute Inc. All Rights Reserved