BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BCNAV
Quartz | Level 8

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

@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

 

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

And CYQXZZZ means the actual letters, CYQXZZZ, correct?

BCNAV
Quartz | Level 8

yes...CYQXZZZ will ALWAYS be present in the text

PeterClemmensen
Tourmaline | Level 20

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
;
data_null__
Jade | Level 19

@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

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1213 views
  • 1 like
  • 3 in conversation