I'm trying to learn the PRX functions.
I want to extract the area_code from a given phone number.
Attached is my log showing the code and the result I got - not fitting
to the expected area code '03'.
73 data _null_; 74 length area_code $3; 75 phone = '03-6789021'; 76 prx_id = prxparse("/\(d+\)D/"); 77 pos = prxmatch(prx_ID, phone); 78 area_code = prxposn(prx_id, 1, phone); 79 put prx_id= pos= area_code=; 80 run; prx_id=1 pos=0 area_code= NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
The expression should look for any number of digits until first non digit character:
Please fix my code and if possible some explanation to my error.
The problem is with the escape character ("\"). "\(" and "\)" look for the actual parantheses in the expression. And "d+" looks for the letter "d", repeated one or more times.
Try "/(\d+)\D/" instead.
The problem is with the escape character ("\"). "\(" and "\)" look for the actual parantheses in the expression. And "d+" looks for the letter "d", repeated one or more times.
Try "/(\d+)\D/" instead.
@s_lassen , thanks very much, it works as expected.
Looking at the solution helped me to understand better the logic of creating the right expression.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.