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.
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.
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
Thanks a ton Ksharp. It works like a charm 🙂
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).
I think Ksharp may be right, using regular expression is a good way~~~
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.
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.