BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Hello,

I have a string like POST 1234 ST NO 50.

I need the string to be standardized as POST 1234 STREET NO 50.In the strings i need to change only ST as STREET.

 

Many Thanks In Adavnce For Your Response,

Sandeep

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20
What sw so you have at hand?
What have you tried so far?
Data never sleeps

View solution in original post

4 REPLIES 4
LinusH
Tourmaline | Level 20
What sw so you have at hand?
What have you tried so far?
Data never sleeps
sandeep_reddy
Quartz | Level 8

HI Linush,

 

I am using SAS Dataflux and standardization node in the data job. When i am trying to replace ST as STREET ,the words like POST is changing as POSTREET.

 

Thanks,

Sandeep

LaurieF
Barite | Level 11

Without seeing the rest of your data, it's hard to give a hard and fast answer. This will work for the example you've given, however:

data _null_;
length address $ 50;
address = 'POST 1234 ST NO 50.';
address = tranwrd(address, ' ST ', ' STREET ');
put address=;
run;

tranwrd changes character strings, whereas translate changes single characters. Note that I have prefixed and suffixed the two strings with spaces, because POST would have been changed as well. However you may strike problems with ST., where a full-stop is after the string - you may have to put in two tranwrd calls to cope with this. I have a very large and complex macro which does exactly this, but it may be more than you need.

 

Note that the parameter order for tranwrd is different to translate (which only changes single characters): the second parameter is what you want to change, the third is what you want it to change to.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

If I was "standardising" that data, I would want to create variables specific for each data element.  E.g.

POST_CODE       STREET_NUMBER

1234                    50

 

Rather than replacing some text, and then having to analyze the text each time I wanted to use it.  

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 976 views
  • 0 likes
  • 4 in conversation