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-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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
  • 839 views
  • 0 likes
  • 3 in conversation