Perl regular expression in SAS. Does anyone knows how I could achieve this using perl regular expressions in SAS. I have this SAS dataset. DATA given; input poolno $ name $; datalines; 00581591 FN MSR0581591 GN 0581591 FN A581591A58591 GN 0581591A FN 0581591BB GN 05815910 FN '0581591 GN ; run; I want to apply below rules using SAS regular expressions. IF LENGTH(POOLNO) > 6 then do the following. Remove all leading zeros Remove 'MRS0' prefix if it exist If a space exists, only keep the portion of the string prior to the space and not including that space Example: ABC 123 -> ABC If the value exists twice, keep only one of them. Example: ABC123ABC123 -> ABC123 If the 7th nonzero character is alphabetical then only keep the 6 nonzero characters prior # to that alphabetical character and not including it. Example: 123456A -> 123456 Remove two trailing characters if they exist Example: 123456BB -> 123456 Remove trailing zeroes after the sixth character Example: 12345600 -> 123456 i. Remove leading ' Example: '123456 -> 123456 This is the desired sas dataset: 0581591 FN 585191 GN 0581591 FN A581591 GN 0581591 FN 0581591 GN 0581591 FN 0581591 GN Thanks in advance for you kind response.
... View more