BookmarkSubscribeRSS Feed
uabcms
Calcite | Level 5

STEVENS MD,STEVE ROBERT

WAINWRIGHT MD,LISA S N
DUDLEY DDS,WARREN
KARZ MD REX H
BROWN,RED
DE LA HOYA OD,RACSO B

 

Need to extract first and last name from a provider list.    Most records contain a title (MD, OD, PT, CRNP, etc) but not all.

The first name on the above list is the most frequent format on the list but there are many other formats - as shown by

records 2-6 above.           Using 9.4

Thanks.

3 REPLIES 3
Reeza
Super User

So what's the rules you've developed so far?

Can you show what you'd expect as output?

 

I think SCAN will get you most of the way there, but there are some formats that will be problematic for sure.

WarrenKuhfeld
Rhodochrosite | Level 12

Something along these lines might be enough to get you started.  This code could fail if a name begins with "OD" and for other reasons.  You might want to deal with the degrees a bit differently.

data x(drop=n);
input n $ 1-40;
name = n;
n = tranwrd(n, ' MD', ' ');
n = tranwrd(n, ' DDS', ' ');
n = tranwrd(n, ' OD', ' ');
if find(n, ',') then last = scan(n, 1, ',');
else last = scan(n, 1, ' ');
if find(n, ',') then first = scan(n, 2, ',');
else first = scan(n, 2, ' ');
first = scan(first, 1);
datalines;
STEVENS MD,STEVE ROBERT
WAINWRIGHT MD,LISA S N
DUDLEY DDS,WARREN
KARZ MD REX H
BROWN,RED
DE LA HOYA OD,RACSO B
;
proc print; run;

 

            Obs    name                       last          first

              1     STEVENS MD,STEVE ROBERT    STEVENS       STEVE 
              2     WAINWRIGHT MD,LISA S N     WAINWRIGHT    LISA  
              3     DUDLEY DDS,WARREN          DUDLEY        WARREN
              4     KARZ MD REX H              KARZ          REX   
              5     BROWN,RED                  BROWN         RED   
              6     DE LA HOYA OD,RACSO B      DE LA HOYA    RACSO 
uabcms
Calcite | Level 5

will give this a try.  Thanks very much.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1494 views
  • 2 likes
  • 3 in conversation