data have;
var='this is sas';
run;
Required output:
thas is sas
by using only translate function
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;
@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.
@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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.