Shared Appendix 11: Creating a Derived Variable Using Process Exits

Table Of ContentsIT Service Vision Help

This information is obsolete and should no longer be used.   Derived variable support has been integrated into IT Service Vision from both the Variable List window of the interactive interface and also by means of the %CPDDUTL macro, using the control statements CREATE DERIVED, UPDATE DERIVED, and DELETE DERIVED.

In order to allow users to surface data that does not exist in the raw data from a collector but which can be calculated from the raw data, IT Service Vision provides the capability of defining formula variables, which are calculated on an as-needed basis, and therefore do not exist as data in the PDB. One of the drawbacks of formula variables is that there is no way to request automatic statistics (at the day, week, month, and year levels of the PDB) for a formula variable.

However, by using the data dictionary, along with the process exit capability of IT Service Vision, you can create your own variables which do exist as stored data and can therefore have automatic statistics at non-detail levels of the PDB and even be used as BY or CLASS variables. Such variables are called derived variables.

This help file will demonstrate the recommended methodology for creating a derived variable. This methodology is applicable for any collector that supports the use of process exits.

The basic steps involved in creating derived variables are:

In the following example, we will add a derived variable called UDERVAR to a table called ANYTABL.

Step 1: Defining the Variable(s) to the Data Dictionary

The derived variable will be stored in the PDB just like the data for any other (non-formula) variable. Therefore, you will need to define the derived variable, following all of the IT Service Vision naming conventions for variables. Like all other variables, the derived variable needs to be defined to the PDB only once.

The following is an example of the %CPDDUTL control statements to define UDERVAR (user-defined derived variable) to the ANYTABL table, assuming that ANYTABL has the variables on which UDERVAR's value is based.

   set table name=anytabl ;
   delete variable name=udervar noerror ;  /* delete if exists */
   create variable name=udervar
      label='Sample derived variable'
      description='Sample derived variable'
      kept=yes interpret=percent type=numeric
      length=8 format=percent7.2
      day=(count sum average std)
      week=(count sum average std)
      month=(count sum average std)
      year=(count sum average std)
      istats=(count sum average std)  ;

In the above example, the value of UDERVAR given for the EXTNAME= parameter is the name of the derived variable, as calculated in the actual SAS statements in the process exits shown in Step 2.

It is essential that for derived variables, the variable name and the external name be defined the same! This is because the process subsystem only performs variable renaming of variables that actually exist in the underlying staged data. If the process subsystem attempts to perform a variable rename and cannot, then the variable is not kept in the output data set. But if a rename is not attempted, the variable is kept in the output data set.

Once the variable has been defined to the data dictionary, you are ready to create and use your exit.

Step 2: Writing the Process Exits to Create the Derived Variable(s)

There is actually very little work to be done in order to create the derived variable. Specifically, we will only be using one exit, proc080, to assign a value to the derived variable.

It would also be possible to add the derived variable using other exit points. However, by using this exit point, the derived variable(s) may also be used as BY variables. (If other exit points were used, the derived variable(s) would not be available at the time the data is sorted. However, regardless of which exit points are used, the derived variables could still be used as CLASS variables for reduction.)

More information on the use of the proc080 exit point follows:

   Exit point proc080 occurs just before the observation is
   written out to the staged data set.

Therefore, we will calculate the value of our derived variable at this point. For our example, let us assume that variable A exists in our table and that it is a measurement of time, which is always less than or equal to the value of the variable DURATION. We can then calculate UDERVAR as a percent, using the following exit:

   %macro proc080;
      %if &CPTABLE=anytabl %then; %* only for the anytabl table ;
            if DURATION ne 0 then
               UDERVAR = A / DURATION ;
               UDERVAR = . ;

Step3: Point to Your Process Exit Using the EXITSRC= Parameter When Running %CxPROCES (CMPROCES, CPPROCES, CSPROCES, or CWPROCES)

All that remains now is to run %CxPROCES, using the EXITSRC= parameter to point to the external library or SAS catalog which contains the exit. After %CxPROCES has run, the detail level of the PDB will have values for the derived variable(s). When %CPREDUCE is run, the requested statistics for the derived variable(s) will be automatically calculated and stored in the various PDB levels.

As mentioned previously, the derived variable does not exist in the underlying staged data. Therefore, you will see the following type of messages in the SAS LOG, when running %CxPROCES:

   WARNING: Variable name UDERVAR in table ANYTABL is not in data set
   NOTE: This may cause missing values to be generated for UDERVAR

These messages should be ignored in the case of derived variables.