Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_validatecol.sas File Reference

Used to validate variables in a dataset. More...

Go to the source code of this file.

Detailed Description

Useful when sanitising inputs, to ensure that they arrive with a certain pattern. Usage:

data test;
  infile datalines4 dsd;
  input;
  libds=_infile_;
  %mp_validatecol(libds,LIBDS,is_libds)
datalines4;
some.libname
!lib.blah
%abort
definite.ok
not.ok!
nineletrs._
;;;;
run;

For more examples, see mp_validatecol.test.sas

Tip - when contributing, use https://regex101.com to test the regex validity!

Parameters
[in]incolThe column to be validated
[in]ruleThe rule to apply. Current rules:
  • ISINT - checks if the variable is an integer
  • ISNUM - checks if the variable is numeric
  • LIBDS - matches LIBREF.DATASET format
  • FORMAT - checks if the provided format is syntactically valid
[out]outcolThe variable to create, with the results of the match

SAS Macros

Related Macros

Version
9.3

Definition in file mp_validatecol.sas.