I have comments with multiple ids which I need to pull from comments. Each I’d in separate column is required.
Input data has 2 columns- comment_id & Comment(it has 1 or more IDs)
Desired output should have 2 columns: comment_id & ID
I am using following function.
For Parsing
data work.comments_parsed;
set work.comments;
if _N_ = 1 then do;
pasre_id=prxparse("/ab[c|d]?e?\d+/");
end;
retain pasre_id;
start = 1;
stops = length(Comment);
run;
For output generation
data work.desired_output;
set work.comments_parsed;
length ID $ 500;
call prxnext(pasre_id, start, stops, Comment, pos, len);
do while (pos >0);
ID = substr(Comment,pos,len);
output;
call prxnext(pasre_id, start, stops, Comment, pos, len);
end;
run;
ERROR: Argument 1 to the function PRXNEXT must be a positive integer returned by PRXPARSE for a valid pattern. ERROR: Internal error detected in function PRXNEXT. The DATA step is terminating during the EXECUTION phase.
I believe error is because of incorrect parsing however when I use prxmatch function by using regular expression directly I am getting proper matching. Can you someone suggest me how I can make this code work.
This code works fine
data pattern_testing;
set work.comments_parsed;
pos = prxmatch("/ab[c|d]?e?\d+?/", Comment);
run;
But this code also gives same error:
data pattern_testing;
set work.comments_parsed;
pos = prxmatch(pasre_id,Comment);
run;