DATA Step, Macro, Functions and more

Perl Regular Expression PRXPARSE

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

Perl Regular Expression PRXPARSE

So I am trying to understand how best to do this using Perl.  I have some sample data which I want to read in as a data step.

 

So 

 

Data work.test;
set work.PerlData;
run;

However I want to use the following

prxparse('/spa/');

I am just not sure how to use this Perl script to show me all hotel names with Spa within it.

 

Excel file looks like: (all fictious data) Just trying to understand Perl before I try it with real data.

 

Hotel_Name Company Phone Manager Email
Ivory Courtyard Resort Ac Metus Vitae LLC (140) 462-6599 Felicia Hutchinson blandit.Nam.nulla@commodoauctor.edu
Sunrise Mirror Resort Quisque Tincidunt Company (544) 574-0753 Hollee Clayton lacinia.at@interdumlibero.edu
Crimson Shore Hotel Et Netus Et Consulting (931) 720-2951 Pascale Bell sapien@vulputate.co.uk
Pleasant Circus Resort & Spa Ut Sem LLP (262) 723-5866 Leonard Middleton elementum.at.egestas@infelisNulla.com
Lord's Plains Hotel Et Netus Corporation (673) 576-3366 Zeus Chan sagittis.felis.Donec@lobortistellus.edu
Noble Refuge Hotel Donec Corporation (110) 924-8302 Leilani Shelton rhoncus@interdum.com
Revelation Hotel & Spa Aliquam Tincidunt Nunc Corp. (559) 588-0513 Armand Bishop eros.Nam.consequat@Aliquameratvolutpat.org
Countryside Hotel Purus Company (241) 761-4967 Seth Slater Duis.elementum.dui@eu.net
Panorama Hotel & Spa Adipiscing Incorporated (113) 803-4658 Tamekah Conrad ligula.Donec@Nunccommodo.com
Stellar Hotel & Spa Magnis Dis Parturient Associates (515) 575-5373 Forrest Haley eu.elit.Nulla@ultriciesdignissimlacus.com
Northern Obelisk Hotel Nec Associates (320) 680-9409 Kim Malone cursus.et@ametmetusAliquam.ca
Western Thicket Resort & Spa Felis Orci Adipiscing Corporation (713) 874-6161 Wang Melendez leo.in@Uttinciduntorci.net
Noble Heritage Hotel Nostra Per LLC (918) 899-8305 Ira Thompson Sed@Proinsed.edu
Ruby Mansion Resort Eu Dui Associates (110) 805-0328 Tobias Britt enim@orcitincidunt.edu

Accepted Solutions
Solution
‎04-19-2017 08:22 AM
Super User
Posts: 10,023

Re: Perl Regular Expression PRXPARSE

Posted in reply to IgawaKei29

if prxmatch('/\bspa\b/i',hotel_name) then output;

View solution in original post


All Replies
Super Contributor
Posts: 345

Re: Perl Regular Expression PRXPARSE

Posted in reply to IgawaKei29

The function prxparse checks the syntax of a regular expression, it does not check wether a something matches the expression. You need to use prxmatch for that.

Contributor
Posts: 23

Re: Perl Regular Expression PRXPARSE

Posted in reply to andreas_lds

Thank you, what would the syntax be for PRXMatch?

Solution
‎04-19-2017 08:22 AM
Super User
Posts: 10,023

Re: Perl Regular Expression PRXPARSE

Posted in reply to IgawaKei29

if prxmatch('/\bspa\b/i',hotel_name) then output;

Contributor
Posts: 23

Re: Perl Regular Expression PRXPARSE

Thank you!  Just starting to get my head wrapped around the syntax

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 164 views
  • 0 likes
  • 3 in conversation