Validar una cadena con expresiones regulares en SAS.

PRXPARSE function returns a pattern identifier number that is used by other Perl functions and CALL routines to match patterns. If an error occurs in parsing the regular expression, SAS returns a missing value. PRXPARSE uses metacharacters in constructing a Perl regular expression. To view a table of common metacharacters, see Tables of Perl Regular Expression (PRX) Metacharacters.

PRXMATCH function searches source with the regular-expression-id that is returned by PRXPARSE, and returns the position at which the string begins. If there is no match, PRXMATCH returns a zero. If you use perl-regular-expression, PRXMATCH searches source with the perl-regular-expression, and you do not need to call PRXPARSE. You can use PRXMATCH with a Perl regular expression in a WHERE clause and in PROC SQL.

 

Ejemplo.

DATA dataDestino ;
    SET dataFuente ;
        expresionRegular = PRXPARSE ("/[^0-9 ]/") ; 
        IF PRXMATCH ( expresionRegular , cadenaEntrada )  THEN  DELETE ; 
RUN ;

 

Fuente de información para PRXPARSE y PRXMATCH

 

¿Que te parecio el contenido?