BookmarkSubscribeRSS Feed

SAS Viya: Add a Customized Quality Knowledge Base (QKB) to CAS and SAS Compute

Started ‎08-30-2023 by
Modified ‎10-02-2023 by
Views 696

In SAS Viya, you can use the SAS Quality Knowledge Base (QKB) to perform data quality operations (e.g., parse and standardize) on your data either in SAS Data Studio (CAS) or in SAS Studio (CAS and/or SAS Compute).  As an Administrator, you can add a customized QKB to your SAS Viya installation.

 

Note:  To learn how to customize a QKB, you can take the Understanding the SAS Quality Knowledge Base VLE course. The QKB Customization Tool can be downloaded from here.

 

The high-level steps to add a customized QKB in SAS Viya for CAS and SAS Compute are:

 

  • Create a QARC (QKB Archive) File for the Customized QKB
  • Add Customized QKB QARC File to CAS
  • Add Customized QKB QARC File to SAS Compute

 

Create a QARC File (QKB Archive) for the Customized QKB

 

A QKB must be in the QARC (QKB Archive) format to be imported to a CAS Server and/or SAS Compute in SAS Viya.  A command-line QARC tool is provided to convert your QKB to this format.  The tool to create the QARC file is available for download here.

 

I downloaded the Windows version of QARC program since the tool used to Customize a QKB is Windows-based, so it is easier to run this process there.

 

1_MK_CustomQKB.png

Select any image to see a larger version.
Mobile users: If you do not see this image, scroll to the bottom of the page and select the "Full" version of this post.

 

The tool needs to be extracted.  I extract the program to my C:\Customized QKBs directory.

 

2a_MK_CustomQKB.png

 

To create a QARC file, first locate the directory of your customized QKB.  In my case it is located at: C:\Customized QKBs\CI33_customized.

 

3_MK_CustomQKB.png

 

Once you have located the directory that contains your customized QKB, then from a Windows command prompt run the following code: 

 

Cd \path\to\qarc.exe
qarc create \path\to\qkb myqkb.qarc

 

In my case I submit the following commands. 

 

cd "C:\Customized QKBs"
qarc create "C:\Customized QKBs\CI33_customized" CI33_customized.qarc

 

Note:  It may take about 10 – 20 minutes to create the QARC file depending on the size of your customized QKB.

 

4_MK_CustomQKB.png

 

The QARC file has been created and is ready to be imported to CAS.

 

Add Customized QKB QARC File to CAS

 

Note:  In order to import the QKB file using the user interface, the QARC file must be in a location accessible from your local machine.

 

5_MK_CustomQKB.png

 

Next, log on to SAS Environment Manager as an Administrator to the Viya installation where you want to add the customized QKB.  You must have SAS Administrator privileges to import a QKB QARC file into SAS Viya.  When signing in, select Yes to assume the group SASAdministrators, so you have the appropriate privileges.

 

6_MK_CustomQKB.png

 

Select Manage Environment to access SAS Environment Manager, then select the Quality Knowledge Bases tab.

 

7a_MK_CustomQKB.png

 

To import a QARC file, select QKBimportButton.png and navigate to where the QARC file for the customized QKB is located by using the Browse button. Enter the target name and server for the QKB.  Select Import to import the file.

 

8_MK_CustomQKB.png

 

Note:  It may take about 5 – 10 minutes to import the QARC file.

 

Once the import is complete, confirm that the imported QKB is now listed.

 

9_MK_CustomQKB.png

 

 

Set Customized QKB as Default QKB in CAS

 

After importing the QKB, to designate the newly imported QKB as the default QKB for your CAS server, add (or change) the configuration settings for the CAS server.

 

In SAS Environment Manager on the Configuration page, select the name of your CAS server. By default, this is cas-shared-default. Edit the sas.cas.instance.config: config section. 

 

10_MK_CustomQKB.png

 

In the Contents area enter the following:  

 

cas.DQSETUPLOC="DefaultQKBName"  
cas.DQLOCALE="DefaultLocale"

 

Note:  The DefaultQKBName must match the name found on the Quality Knowledge Bases page of SAS Environment Manager.  The DefaultLocale is the 5-character QKB locale abbreviation.  For example, ENUSA = English-United States and ESESP = Spanish-Spain. SAS Quality Knowledge Base for Contact Information 33 - QKB Locale ISO Codes

 

Below are my modified config settings to set my imported Customized QKB as the new default QKB.

 

11_MK_CustomQKB.png

 

After editing this configuration setting, you need to restart the sas-data-quality pod for the change to take effect by issuing the following commands: 

  

kubectl -n name-of-namespace delete pods -l app.kubernetes.io/managed-by=sas-cas-operator

kubectl -n name-of-namespace get pods | grep sas-data-quality


kubectl -n name-of-namespace delete pod sas-data-quality-pod-name

 

Note:  In the last command, replace sas-data-quality-pod-name with the name of the pod that is returned by the second command. This enables the automatic import of the QKB that is specified by the DQSETUPLOC server option.

 

Here is what I submitted to restart the sas-data-quality pod for my SAS Viya installation.  Note: My namespace is gelenv.

 

12_MK_CustomQKB.png

 

Finally, after waiting a few minutes for the sas-data-quality pod to restart, return to the Quality Knowledge Bases tab in SAS Environment Manager and refresh the display to confirm that the Customized QKB is now set as the default QKB.

 

13_MK_CustomQKB.png

 

Note: It will take a few minutes for the pod to restart and reflect this change.  It will display a message “No QKBs were found” until the pod is fully restarted.

 

Add Customized QKB QARC File in SAS Compute

 

To add the customized QKB to SAS Compute, upload its .qarc file to a location on your SAS Server. I uploaded mine here: /shared/gelcontent/Customized_QKBs/.

 

14_MK_CustomQKB.png

 

Next, you need to find the location of the QKB bash scripts for your SAS Viya installation by issuing the following command. 

 

find . -name containerize-qkb.sh

 

15_MK_CustomQKB.png

 

In my case the QKB bash scripts are located here: ./project/deploy/gelenv/sas-bases/examples/data-quality/scripts/

 

Next, change directory to that location:

 

16_MK_CustomQKB.png

 

Then, run the following command to containerize your customized QKB:

 

bash containerize-qkb.sh "My Customized QKB" /path/to/myqkb.qarc registry.mycompany.com/mycustomizedqkb:v1

 

Note: registry name must be in lowercase with no spaces.

 

17_MK_CustomQKB.png

 

Note: It may take a few minutes for this script to complete.

 

Next, run the following command to deploy the customized QKB.

 

bash deploy-qkb.sh registry.mycompany.com/mycustomizedqkb:v1 | kubectl apply -n my-namespace -f –

 

18_MK_CustomQKB.png

 

 

Then run this command to create the sas-quality-knowledge-base-list-job.

 

bash list-qkbs.sh | kubectl apply -n my-namespace -f –

 

19_MK_CustomQKB.png

 

Then run the following command to get a list of registered QKBs for SAS Compute:

 

kubectl -n my-namespace logs job.batch/sas-quality-knowledge-base-list-job-nameReturnedFromPreviousCommand

 

20_MK_CustomQKB.png

 

All registered QKBs in SAS Compute are displayed including the customized one you just registered. Finally, run the following command to delete the sas-quality-knowledge-base-list-job you just created.

 

kubectl -n my-namespace delete job.batch/sas-quality-knowledge-base-list-job-nameReturnedFromPreviousCommand

 

21_MK_CustomQKB.png

 

 

Set Default QKB in SAS Compute

 

In SAS Environment Manager on the Configuration page, select Compute service. Edit the sas.compute.server: configuration_options section. 

 

22_MK_CustomQKB.png

 

 

In the Contents area enter the following:

 

-DQSETUPLOC "DefaultQKBName"
-DQLOCALE (DefaultLocale)

 

Note:  The DefaultQKBName must match the name of the customized QKB returned from the listing of registered QKBs for SAS Compute.  The DefaultLocale is the 5-character QKB locale abbreviation.  For example, ENUSA = English-United States and ESESP = Spanish-Spain. SAS Quality Knowledge Base for Contact Information 33 - QKB Locale ISO Codes

 

Edited_23_MK_CustomQKB.png

 

Log out of all SAS Compute sessions. Must re-open compute session for change to take effect.  I sign-out and close my browser with Viya.  I re-open and sign back into my Viya installation.

 

In SAS Studio, test with a definition in the default locale specified for your default customized QKB to confirm customized QKB is being used.

 

A custom parse definition in my customized QKB is Clothing.   

 

data _null_;
   version=DQVERQKB();
   token_names=DQPARSEINFOGET('Clothing');
   put version;
   put token_names;
run;

 

24_MK_CustomQKB.png

 

I have now confirmed that SAS Compute is using my customized QKB and default locale setting. Refer to the SAS Data Quality Language Reference section in the SAS Data Quality guide other code examples you can test with.

 

Summary

You can use your customized SAS Quality Knowledge Base (QKB) in both CAS and SAS Compute in SAS Viya to perform data quality operations.  Refer to the QKB Management section in the SAS Data Quality guide for more information.

 

 

Find more articles from SAS Global Enablement and Learning here.

Version history
Last update:
‎10-02-2023 08:52 AM
Updated by:
Contributors

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags