SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

SAS DATA Standardization

Accepted Solution Solved
Reply
Contributor
Posts: 61
Accepted Solution

SAS DATA Standardization

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


Accepted Solutions
Solution
‎02-03-2017 04:44 AM
Super User
Posts: 5,424

Re: SAS DATA Standardization

Posted in reply to sandeep_reddy
What sw so you have at hand?
What have you tried so far?
Data never sleeps

View solution in original post


All Replies
Solution
‎02-03-2017 04:44 AM
Super User
Posts: 5,424

Re: SAS DATA Standardization

Posted in reply to sandeep_reddy
What sw so you have at hand?
What have you tried so far?
Data never sleeps
Contributor
Posts: 61

Re: SAS DATA Standardization

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

Super Contributor
Posts: 252

Re: SAS DATA Standardization

Posted in reply to sandeep_reddy

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.

Super User
Super User
Posts: 7,942

Re: SAS DATA Standardization

Posted in reply to sandeep_reddy

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.  

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 294 views
  • 0 likes
  • 4 in conversation