BookmarkSubscribeRSS Feed
rajeshalwayswel
Pyrite | Level 9
data have;
var='this is sas';
run;

Required output:

thas is sas 

by using only translate function
4 REPLIES 4
PaigeMiller
Diamond | Level 26

You mean we can't use SCAN or SUBSTR or TRANWRD?

 

Anyway, it is impossible to generalize a single example so we can write meaningful code. Can you give us a more meaningful and realistic example?

 

here is non-meaningful code, I didn't even need to use TRANSLATE.

 

data want;
    set have;
    if var='this is sas' then var='thas is sas';
run;

 

--
Paige Miller
rajeshalwayswel
Pyrite | Level 9
yes, we have lot of ways to do this. But in interview asked me how can we do by only this function.
ballardw
Super User

@rajeshalwayswel wrote:
yes, we have lot of ways to do this. But in interview asked me how can we do by only this function.

I suspect that if the interviewer was that specific and knowledgeable, or had a prepared list of answers, may have been looking for "Can't do that with Translate, you may have meant Tranwrd" since translate replaces all occurrences of specified characters with the specified target.

PaigeMiller
Diamond | Level 26

@ballardw wrote:

@rajeshalwayswel wrote:
yes, we have lot of ways to do this. But in interview asked me how can we do by only this function.

I suspect that if the interviewer was that specific and knowledgeable, or had a prepared list of answers, may have been looking for "Can't do that with Translate, you may have meant Tranwrd" since translate replaces all occurrences of specified characters with the specified target.


If your suspicion is correct, I think this is a terrible interview question,and unfortunate for the interviewee, but that's my opinion. It could also be that whoever prepared the question him(her)self had confused TRANSLATE and TRANWRD, which would be doubly unfortunate for the interviewee.

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 585 views
  • 0 likes
  • 3 in conversation