BookmarkSubscribeRSS Feed

SAS Viya 3.4: Use a Non-Default Quality Knowledge Base (QKB)

Started ‎08-28-2019 by
Modified ‎08-28-2019 by
Views 2,288

In my previous article, I reviewed how you could add a customized Quality Knowledge Base (QKB) to your SAS Viya 3.4 installation.  This results in more than one QKB instance that is available for use in SAS Viya 3.4. In this article, I will review how you can use one of the non-default designated QKB instances in SAS Viya 3.4


Currently, in SAS Viya 3.4, you can only use the designated default QKB instance in SAS Data Studio. If you want to use a non-default QKB instance in your data quality operations, then you must use code in SAS Studio. SAS Studio will use the default assigned QKB unless otherwise specified. Let's take a look at how to specify the use of an alternate QKB in SAS Studio.


First, you need to confirm the QKB Name for the non-default QKB instance you want to you use. You can view the QKB Name on the Quality Knowledge Bases tab in SAS Environment Manager.



Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.


In my case, the non-default QKB Name is CI29_qkb1_customized.


Next, you need to log on to SAS Studio.

Note: You can use either SAS Studio 4 or 5. For the purposes of this article, I will use SAS Studio 5.




When declaring your CAS session, you specify the alternate QKB to use as part of your session options. The syntax for the QKB session options are:


dqSetupLoc="QKB Name to use in session"

dqLocale="5-character locale abbreviation to use in session"


For example, ENUSA = English-United States and ESESP = Spanish-Spain.

Note: The dqLocale option is optional, but if you specify it here, then you can leave off the QKB Locale setting when calling the definitions in the code.


Below is the code to set my CAS session to use the CI29_qkb1_customized QKB instance and the ENUSA locale.


cas mySession sessopts=(caslib="casuser" timeout=1800 locale="en_US"
dqSetupLoc="CI29_qkb1_customized" dqLocale="(ENUSA)";




This statement is technically all that is needed to use an alternate (non-default) QKB instance in your SAS Studio session for SAS Viya 3.4. However, let's look at an example that uses some definitions from this alternate QKB to show that the alternate QKB is being used in the SAS Studio session.


In my CI29_qkb1_customized QKB instance, I have an Auto standardization and parse definitions that I will use to perform some data quality operations against a table loaded in CAS. The Auto definitions use the tokens of Make, Model, and Year. For example, the data 2019 Toyota Camry would parse as follows:


Year:   2019

Make: Toyota

Model: Camry.


Below is a screenshot of the AUTOINFO.sashdat data that will be cleansed using the Auto definitions from the alternate QKB – CI29_qkb1_custmomized. The data to be standardized and then parsed into the tokens Year, Make, and Model is in a field named AutoInfo.




Here is the code I used in SAS Studio 5 to standardize and parse the AutoInfo data into the columns Year, Make, and Model and create the in-memory and physical AUTOINFO_CLEANSED tables.


/* Create CAS Session with QKB and Locale to Use */
cas mySession sessopts=(caslib="casuser" timeout=1800 locale="en_US" dqSetupLoc="CI29_qkb1_customized" dqLocale="(ENUSA)");

/* assign all CAS libraries to session */
caslib _all_ assign;

/* drop global in-memory AUTOINFO and AUTOINFO_CLEANSED tables and physical AUTOINFO_CLEANSED.sashdat table if they exist */
proc casutil;
   droptable casdata="AUTOINFO" incaslib="Public" quiet;
   droptable casdata="AUTOINFO_CLEANSED" incaslib="Public" quiet;
   droptable casdata="AUTOINFO_CLEANSED.sashdat" incaslib="Public" quiet;

/* Load AUTOINFO table to memory */
proc casutil;
   load casdata="AUTOINFO.sashdat" casout="AUTOINFO" incaslib="Public" outcaslib="Public" promote;

/* Perform Data Quality operations on AUTOINFO in-memory table to standardize and parse
  / sessref=mySession at the end of data step statement indicates to run the data step within CAS
  AUTOINFO_CLEANSED is created as a global in-memory table */

data Public.AUTOINFO_CLEANSED (promote=yes) / sessref=mySession;
   set Public.AUTOINFO;
   AutoInfo_Stnd=dqstandardize(AutoInfo, 'Auto', 'ENUSA');
   parsedValue=dqparse(AutoInfo_Stnd, 'Auto', 'ENUSA');
   Year=dqParseTokenGet(parsedValue,'Year', 'Auto', 'ENUSA');
   Make=dqParseTokenGet(parsedValue,'Make', 'Auto', 'ENUSA');
   Model=dqParseTokenGet(parsedValue,'Model', 'Auto', 'ENUSA');
   drop AutoInfo_Stnd;
   drop parsedValue;
   drop AutoInfo;

/* Save AUTOINFO_CLEANSED physical table */
proc casutil;
   save casdata="AUTOINFO_CLEANSED" casout="AUTOINFO_CLEANSED" incaslib="Public" outcaslib="Public" replace;

/* Terminate Session */
cas mySession terminate;


Below is a screenshot of the resulting AUTOINO_CLEANSED.sashdat table where the original AutoInfo data has been standardized and parsed into the columns Year, Make, and Model by using the Auto definitions from the alternate QKB – CI29_qkb1_customized.




For more information on SAS Data Quality in SAS Viya refer to its documentation.

Version history
Last update:
‎08-28-2019 10:04 AM
Updated by:



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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