Download presentation
Presentation is loading. Please wait.
Published byPolly Adams Modified over 8 years ago
1
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Learning SAS’s Perl Regular Expression Matching the Easy Way: By Doing Author: Paul Genovesi, Henry Jackson Foundation
2
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Presentation Topics Review of prxmatch() and prxchange() functions. regex_learning_tool contents. Perl-regular-expression (PRX) processing. Substitution-PRX processing. Commenting out a match record. Running an ordered list or a program. Obtaining a copy of the project and Excel file. 2
3
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 SAS’s prxmatch() function is used for matching only Syntax: prxmatch(perl-regular-expression, source) Example: data _null_; position = prxmatch(‘/world/’, 'Hello world!'); put position=; run; SAS log output: position=7 3
4
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 SAS’s prxchange() function is used for matching and substitution Syntax: prxchange(substitution-perl-regular-expression, times, source) Example: data _null_; name = 'Jones, Fred'; name = prxchange('s/(\w+), (\w+)/$2 $1/', -1, name); put name=; run; SAS log output: name=Fred Jones 4
5
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 regex_learning_tool contents regex_learning_tool.egp input_file.xlsx 5
6
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 The Excel file contains two types of match records / / perl-regular-expression s/ / / substitution-perl-regular-expression 6
7
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Processing perl-regular-expression (PRX) match records prxmatch(regex, source) 7
8
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 PRX match record output (SAS dataset) The Excel file’s original 4 fields are high- lighted. 8
9
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Processing substitution-PRX match records prxchange(regex, times, source) 9
10
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Substitution-PRX match record output Only substitution-PRX match records will have output in these two fields. 10
11
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 prxchange() functions create output for substitution-PRX match records prxchange(s/ / /, 1, source) prxchange(s/ / /, -1, source) 11
12
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Commenting out a match record in the Excel file Prepend an asterisk within the regex field… 12 …and Output will indicate it was not processed.
13
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Ordered List versus Program Every ordered list has a corresponding program with the same name. 13
14
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Ordered List versus Program Running an ordered list does two things: 1. Imports Excel file data. 2. Runs the same-named program. Running a program does not import Excel file data. 14
15
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Running an Ordered List Right-click on an ordered list and then click run. 15
16
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Running a Program Right-click on a program and then click Run. 16
17
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 A list of all ordered lists 17
18
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Common pop-up message If you receive the following pop-up message when attempting to either run an ordered list or save the project, then just click ‘ok.’ Every ordered list contains a call to the 2 mentioned items and you are being made aware of that. 18
19
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Worth mentioning Output comes in the form of a SAS dataset or SAS report. 19
20
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Obtaining a copy of the project and Excel file Obtaining a copy of regex_learning_tool will be discussed at the conference. 20
21
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Questions? Please ask… 21
22
Distribution A: Approved for public release; distribution is unlimited. Case Number: 88ABW-2014-4183, 4 Sep 2014 Contact Information Paul Genovesi Henry Jackson Foundation for the Advancement of Military Medicine Inc. Wright-Patterson AFB, Ohio pcg7285g@gmail.com 22
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.