Macros for SAS Application Developers
https://github.com/sasjs/core
mp_filtercheck.sas File Reference

Checks an input filter table for validity. More...

Go to the source code of this file.

Detailed Description

Performs checks on the input table to ensure it arrives in the correct format. This is necessary to prevent code injection. Will update SYSCC to 1008 if bad records are found, and call mp_abort.sas for a graceful service exit (configurable).

Used for dynamic filtering in Data Controller for SAS®.

Usage:

%mp_filtercheck(work.filter,targetds=sashelp.class,outds=work.badrecords)

The input table should have the following format:

GROUP_LOGIC:$3 SUBGROUP_LOGIC:$3 SUBGROUP_ID:8. VARIABLE_NM:$32 OPERATOR_NM:$10 RAW_VALUE:$4000
AND AND 1 AGE = 12
AND AND 1 SEX <= 'M'
AND OR 2 Name NOT IN ('Jane','Alfred')
AND OR 2 Weight >= 7

Rules applied:

  • GROUP_LOGIC - only AND/OR
  • SUBGROUP_LOGIC - only AND/OR
  • SUBGROUP_ID - only integers
  • VARIABLE_NM - must be in the target table
  • OPERATOR_NM - only =/>/</<=/>=/BETWEEN/IN/NOT IN/NE/CONTAINS
  • RAW_VALUE - no unquoted values except integers, commas and spaces.
Returns
The &outds table containing any bad rows, plus a REASON_CD column.
Parameters
[in]indsThe table to be checked, with the format above
[in]targetds=The target dataset against which to verify VARIABLE_NM. This must be available (ie, the library must be assigned).
[out]abort=(YES) If YES will call mp_abort.sas on any exceptions
[out]outds=(work.badrecords) The output table, which is a copy of the &inds. table plus a REASON_CD column, containing only bad records. If bad records are found, the SYSCC value will be set to 1008 (a general data problem). Downstream processes should check this table (and return code) before continuing.

SAS Macros

Related Macros

Version
9.3
Author
Allan Bowe
Todo:
Support date / hex / name literals and exponents in RAW_VALUE field

Definition in file mp_filtercheck.sas.