BookmarkSubscribeRSS Feed
Ujjawal
Quartz | Level 8

I want to group some values into one value. For eg : I have data for college names and some names are written in short form and some in full forms. The task is to group them into one name. I am using TRANWRD function to do it. Is it possible to group multiple values into one using TRANWRD function? I know the two datasets can be merged for it.

5 REPLIES 5
ballardw
Super User

Examples of what you have and what you want. Depending on the number of records you might be able to create a format but tranwrd isn't going to get you there without a many lines of code though it can regularize some things common contractions to a single standard.

Ksharp
Super User

You need multiple tranwrd() for that purpose . But you can combine them all into one function :

if prxmatch('/ArthurT|ArthurC|ArthurK/',name) then name='Arthur' ;

Xia Keshan

Ujjawal
Quartz | Level 8

Thanks a ton Ksharp. It works like a charm 🙂

LinusH
Tourmaline | Level 20

I think you are on the wrong track. Spelling variations will most likely expand over time, and you don't to update your program each time.

Use a look-up table with incorrect - correct (normalized) spelling pairs. Then use the look-up technique you feel most comfortable with (user defined formats, SQL join etc).

Data never sleeps
Albert_Feng
Calcite | Level 5

I think Ksharp may be right, using regular expression is a good way~~~

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 2987 views
  • 2 likes
  • 5 in conversation