Regular Expressions in SAS Enterprise Guide
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Regular Expressions in SAS Enterprise Guide

  • 1,551 views
Uploaded on

In version 9, the SAS® System introduces Perl regular expressions (sometimes known by the acronym PRX, the first three letters of these functions or call routines). However, previous versions of......

In version 9, the SAS® System introduces Perl regular expressions (sometimes known by the acronym PRX, the first three letters of these functions or call routines). However, previous versions of SAS® already had regular expressions (known by their acronym RX, the first two letters of these functions or call routines). This presentation will describe specific functional and performance differences in these two exclusive regular expression strategies, and offer recommendations on when to use each strategy. The technologies will be compared using SAS Enterprise Guide® 4.3.

More in: Business , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,551
On Slideshare
1,443
From Embeds
108
Number of Embeds
2

Actions

Shares
Downloads
9
Comments
0
Likes
0

Embeds 108

http://marktab.net 83
http://www.marktab.net 25

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Regular Expressions in SAS®Enterprise Guide®Mark Tabladillo Ph.D.http://www.marktab.com@marktabnet
  • 2. Introduction Regular expressions are the foundation of character pattern matching Textual data is increasingly important in predictive analytics SAS Enterprise Guide® offers regular expression processing
  • 3. Outline Guide for Migrating from SAS (RX) expressions to Perl (PRX) regular expressions Best practices for Perl Regular Expressions Advanced Perl Regular Expression Capabilities Demo
  • 4. How to Migrate from SAS(RX) to Perl(PRX) Regular Expressions
  • 5. Upgrade to Perl (PRX) Regular ExpressionsSAS (RX) Perl (PRX) DescriptionRXPARSE PRXPARSE Compiles a regular expression (RX or PRX) that can be usedFunction Function for pattern matching of a character valueRXMATCH PRXMATCH Searches for a pattern match and returns the position at whichFunction Function the pattern is foundCALL CALL Returns the position and length of a substring that matches aRXSUBSTR PRXSUBSTR pattern (RX includes score)Routine RoutineCALL CALL Performs a pattern-matching replacementRXCHANGE PRXCHANGERoutine Routine PRXCHANGE FunctionCALL RXFREE CALL PRXFREE Frees unneeded memory allocated for a regular expressionRoutine Routine (either RX or PRX)
  • 6. How to Best Use Perl RegularExpressions
  • 7. Categories of Regular ExpressionCommandsCategory Single-Line Proc SQL Data Step Macro CommandAccepts Perl YES YES YES YESRegularExpressionAccepts no YES YES YESRegularExpression IDHas CALL no no YES YESRoutineVariant
  • 8. Regular Expression Commands (1 of 3) Description Accepts Perl Accepts Regular Has a CallCommand Regular Expression ID Routine Variant ExpressionPRXCHANGE Performs a pattern- YES YES YES matching replacement.PRXDEBUG Enables Perl regular no no YES expressions in a DATA step to send debugging output to the SAS log.PRXFREE Frees memory that was no no YES allocated for a Perl regular expression.
  • 9. Regular Expression Commands (2 of 3) Description Accepts Perl Accepts Regular Has a CallCommand Regular Expression ID Routine Variant ExpressionPRXMATCH Searches for a pattern YES YES no match and returns the position at which the pattern is found.PRXNEXT Returns the position no no YES and length of a substring that matches a pattern, and iterates over multiple matches within one string.PRXPAREN Returns the last bracket no YES no match for which there is a match in a pattern.
  • 10. Regular Expression Commands (3 of 3) Description Accepts Perl Accepts Regular Has a CallCommand Regular Expression ID Routine Variant ExpressionPRXPARSE Compiles a Perl regular YES no no expression (PRX) that can be used for pattern matching of a character value.PRXPOSN Returns a character no YES YES string that contains the value for a capture buffer.PRXSUBSTR Returns the position no no YES and length of a substring that matches a pattern.
  • 11. Advanced Regular ExpressionCommands
  • 12. Commands DescriptionPerl (PRX)CALL PRXPOSN Returns the start position and length for a capture bufferRoutinePRXPOSN Function Returns the value for a capture bufferPRXPAREN Function Returns the last bracket match for which there is a match in a patternCALL PRXNEXT Returns the position and length of a substring thatRoutine matches a pattern and iterates over multiple matches within one stringCALL PRXDEBUG Enables Perl regular expressions in a DATA step to sendRoutine debug output to the SAS log
  • 13. Demos
  • 14. Conclusion See the Paper for Details  Guide for Migrating from SAS (RX) expressions to Perl (PRX) regular expressions  Best practices for Perl Regular Expressions  Advanced Perl Regular Expression Capabilities  Demo Contact  http://www.marktab.com  http://www.marktab.net  @marktabnet
  • 15. Abstract In version 9, the SAS® System introduces Perl regular expressions (sometimes known by the acronym PRX, the first three letters of these functions or call routines). However, previous versions of SAS® already had regular expressions (known by their acronym RX, the first two letters of these functions or call routines). This presentation will describe specific functional and performance differences in these two exclusive regular expression strategies, and offer recommendations on when to use each strategy. The technologies will be compared using SAS Enterprise Guide® 4.3.
  • 16. Mark Tabladillo / MarkTab Consulting