SAS9 Regular Expression Test (for a string of strings)

xiaoxiao2021-03-06  62

SAS9 Regular Expression Test (for a string of strings)

The test case is as follows:

1, no string replacement without using regular expressions

Data _null_;

Length A B $ 2000;

DO i = 1 to 500;

a = "dsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssss

Ssssssssssssssssssssssssssssssss ";

B = TRANWRD (A, "S", "W");

END;

PUT A = B =;

Run;

The result of the operation is:

Note: Time used in "DATA statement":

Actual time 0.47 seconds

CPU time 0.47 seconds

2, use the regular expression to replace the string

Data _null_;

Length A B $ 2000;

GT_RE = prxParse ('s / s / w / ");

DO i = 1 to 500;

a = "dsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdsfdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss";

B = a;

Call Prxchange (gt_re, -1, b);

END;

PUT A = B =;

Run;

The result of the operation is:

Note: Time used in "DATA statement":

Actual time 45.71 seconds

CPU time 43.91 seconds

After test, it can be seen that the running time of 2 is very different, not a level

Therefore, it is recommended that it is best not to use regular expressions in programs that are required to run speed.

转载请注明原文地址:https://www.9cbs.com/read-113905.html

New Post(0)