SAS String Routines


PrsSubStr

The PRSSUBSTR routine sets the character position and character length of a regular expression match into external variables. For example:

call prssubstr("/[Ff][Oo]{2}/", foobar, foo_start, foo_length);
if (foo_start > 0) then foo = substr(foobar, foo_start, foo_length);


PrxNext

The PRXNEXT routine sets the character position and character length of a regular expression match into external variables, while obeying start and end character positions. This enables looping over a string for regular expression matches. For example:

routine_start = 1;
routine_end = length(foobar);

call prxnext("/[Ff][Oo]{2}/", routine_start, routine_end, foobar, foo_start, foo_length);
do while (mystart > 0);
  mystring = substr(STRING, foo_start, foo_length);
  call prxnext("/[Ff][Oo]{2}/", routine_start, routine_end, foobar, foo_start, foo_length);
end;


CategoryRicottone

SAS/StringRoutines (last edited 2023-01-14 05:03:43 by DominicRicottone)