Hi all,
I have a need to parse some incoming airline messages. One of the text messages (called MSG_RAW_TEXT) can have any flight-related information. I am interested in finding only messages that CONTAIN:
[0-3][0-9][0-2][0-9][0-5][0-9] CYQXZZZ[A-Z]
This means the first character can be 0,1,2,3; the second can be 0 to 9, the third can be 0-2, etc.
Other pieces of information could be in the text...thanks
@BCNAV wrote:
[0-3][0-9][0-2][0-9][0-5][0-9] CYQXZZZ[A-Z]
This means the first character can be 0,1,2,3; the second can be 0 to 9, the third can be 0-2, etc.
This looks like a regular expression.
388 data _null_;
389 input string $80.;
390 x = prxmatch('/[0-3][0-9][0-2][0-9][0-5][0-9] CYQXZZZ[A-Z]/',string);
391 put _all_;
392 cards;
string=492949 CZQXZZZF x=0 _ERROR_=0 _N_=1
string=392949 CYQXZZZF x=1 _ERROR_=0 _N_=2
x=1 means found
And CYQXZZZ means the actual letters, CYQXZZZ, correct?
yes...CYQXZZZ will ALWAYS be present in the text
Something like this?
data have;
input msg $20.;
if prxmatch('/[0-3][0-9][0-2][0-9][0-5][0-9]CYQXZZZ[A-Z]/',msg)>0 then output;
datalines;
fiwejofjwofjw
241748CYQXZZZA
946248CYQXZZZB
301748CYQXZZZQ
;
@BCNAV wrote:
[0-3][0-9][0-2][0-9][0-5][0-9] CYQXZZZ[A-Z]
This means the first character can be 0,1,2,3; the second can be 0 to 9, the third can be 0-2, etc.
This looks like a regular expression.
388 data _null_;
389 input string $80.;
390 x = prxmatch('/[0-3][0-9][0-2][0-9][0-5][0-9] CYQXZZZ[A-Z]/',string);
391 put _all_;
392 cards;
string=492949 CZQXZZZF x=0 _ERROR_=0 _N_=1
string=392949 CYQXZZZF x=1 _ERROR_=0 _N_=2
x=1 means found
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: