Hi All
I have a challenge to identify a particular pattern in the data, for example
AB, YZ
AB, AB, YZ
AB, AB, AB, YZ
...
if string AB comes before string YZ, i need to identify these records, but AB can be any number of times (i.e. 1 to n)
Any thoughts?
So in this example, all three records would be identified, correct?
Try to check by:
if scan(<variable namr>, -1, ' ,') = 'BZ' and /* last string */
scan(<variable namr>, -2, ' ,') = 'AB'
then ...; else ...;
Regular expressions are all about text patterns.
if prxMatch("/AB[, ]+YZ/i", string) then <do something>;
would match your example pattern. The pattern says: AB followed by one or more comma or a space characters, followed by YZ.
If it is really as simple as your example then no need for regular expressions.
index(string,'AB, YZ')
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.