Hi all,
I would like to do the following searching in my sample test dataset.
1. Searching 4 numbers + 2 letters afterwards
2. Searching any numbers starting with 000.
The result I am looking for is in the Find column.
data Text;
infile datalines dsd;
input TempID : $15. TempID_1 : $15. TempID_2 : $15. TempID_3 : $15. TempID_4 : $15. Find : $10. ;
datalines;
1156 IL, 89__46, 88--53, , , 1156IL
1487-KM, __8956, _78-52__, Car 4632, , 1487KM
000-597, -1596_, 4113, , , 000597
C_ _-1156, 4986__, 0_0-0_8, , , 0008
208, 8M _ O23, , , Car ID 7788 GH, 7788GH
HB_21156--, 89 66, 885 - 2, 5 5 5 9, 0056,
;
Like this?
%* Finds 4 digits, then an optional non-word character, then 2 letters;
POS1 = prxmatch('/\d{4}\W?[a-zA-Z]{2]/' , TEMP_ID);
%* Finds 3 zeros then a series of one or more digit(s);
POS2 = prxmatch('/000\d+/' , TEMP_ID);
What do you do once you find these?
Like this?
%* Finds 4 digits, then an optional non-word character, then 2 letters;
POS1 = prxmatch('/\d{4}\W?[a-zA-Z]{2]/' , TEMP_ID);
%* Finds 3 zeros then a series of one or more digit(s);
POS2 = prxmatch('/000\d+/' , TEMP_ID);
What do you do once you find these?
@ybz12003 The values in Find are not according with the description you have posted, please fix it.
Don't worry about it, I found the solution myself. Thanks for your help!
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 lock in 2025 pricing—just $495!
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.