Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6934359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:56:59+00:00 2026-05-27T11:56:59+00:00

I was attempting to use regular expressions in a SAS SQL statement and couldn’t

  • 0

I was attempting to use regular expressions in a SAS SQL statement and couldn’t get them working. It runs, but it doesn’t return the matched expression (column xx is always blank). Not sure if this is something I’m doing wrong or if SAS doesn’t let you do this.

proc sql noprint;
  create table xx as
  select *,
         prxposn(prxparse("/a/i"), 0, name) as xx
  from sashelp.class
  ;
quit;

Thanks
Rob

EDIT: I know I could just do the PROC SQL and then do the regex in a datastep – I can get that working fine, I just want to know if it’s possible to do it all in the PROC sql.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:57:00+00:00Added an answer on May 27, 2026 at 11:57 am

    I don’t think the documentation is particularly clear on the matter, but “the PRXPOSN function uses the results of PRXMATCH, PRXSUBSTR, PRXCHANGE, or PRXNEXT to return a capture buffer” and so you have to call one of those functions first, using the regular expression ID you generate via PRXPARSE, prior to calling PRXPOSN.

    The following SAS code works for me on 9.1.3. Your intention is not entirely clear to me, but I’m assuming you want to capture the suffix starting from the first “a”, and so I modified your regular expression accordingly:

    proc sql; 
       create table xx as 
       select *, 
          prxparse("/a\w*/i") as re,
          ifc(
             prxmatch(calculated re, name), 
             prxposn(calculated re, 0, name), 
             " "
          ) as xx 
       from sashelp.class; 
    quit; 
    

    One downside to this approach (besides its decided lack of elegance) is that it adds an additional variable (re) to the output data set. The following sources were helpful to me in tracking down the behavior of PRXPOSN:

    • http://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf
    • http://communities.sas.com/thread/30443
    • http://groups.google.com/group/comp.soft-sys.sas/browse_thread/thread/15ec39268d497990/d2eaf9c4512ee0b5?lnk=gst&q=prxposn&pli=1
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are attempting to use a SQL Server 2003 database for our test records
I'm attempting to use the Interactive Brokers ActiveX API, but I'm having a little
I am attempting to use regex matching to get a list of optional params
I am attempting to fix some bilingual xml files using regular expressions to match
I'm attempting to create a regular expression to use as a filter in DeltaWalker.
I'm attempting to use the rest-client gem to post something, but for some reason,
I'm attempting to use an AsyncTask to read from a file at regular intervals.
I am attempting use Java Pathfinder and I have pathfinder working. import gov.nasa.jpf.jvm.Verify; user.java:2:
I am attempting to use Filestream in sql server 2008 to store user uploaded
I'm attempting to parse an Oracle trace file using regular expressions. My language of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.