I've set up a simplified DI Studio job for a problem. It has a source data set that contains invalid email adresses (SS_EMAIL), and an Extract transformation that I'd like to use to correct them. There's two kinds of invalid email adresses:
1) user@.domain.com, which should become user@domain.com
2) user@ domain.com, which should become user@domain.com
What kind of expression can I use to make these two corrections? They'll be fixed in the source data eventually, but that might take weeks so my job must be able to handle them for the time being.
Thanks for your time.
The exact syntax you will have to write by yourself.
But it could involve finding the position right after the @-sign, and test if this position is not a special char (see NOTALNUM Function and others).
Can you use tranwrd? e.g.:
data have;
informat email $50.;
input email &;
email=tranwrd(tranwrd(email,"@.","@"),"@ ","@");
cards;
user@.domain.com
user@ domain.com
;
how about using my favorite function tranwrd?:
data email;
length emailin emailout $200;
emailin = 'user@.domain.com';
emailout = tranwrd(tranwrd(emailin,'@ ','@'),'@.','@');
output;
emailin = 'user@ domain.com';
emailout = tranwrd(tranwrd(emailin,'@ ','@'),'@.','@');
output;
run;
Regards Fredrik
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.