1

In mysql this would look like: substring_index(email, '@', -1)

But I can't seem to find if a function like this is available in SAS proc sql.

max
  • 671
  • 5
  • 13

2 Answers2

2

this seems to work

data _null_;
x='rxx@gmail.com';
dom=substr(x,findc(x,'@'));
put dom;
run;
DCR
  • 14,737
  • 12
  • 52
  • 115
  • 1
    you are the one man! this worked. My rep isn't higher but consider this +1'ed – max Apr 13 '18 at 18:09
  • Use comments to ask for more information or suggest improvements. Avoid comments like "+1" or "thanks". – jchevali Apr 13 '18 at 18:13
0

Use FINDW to find the position of @ and SUBSTR to return the remainder?

jchevali
  • 171
  • 10
  • 1
    sounds like it could work - haven't been able to write the exact function using those two functions yet though. – max Apr 13 '18 at 17:37
  • In other languages such as SQLite, where FINDW is called instr(), it'd be something like substr('mail@server',1+instr('mail@server','@')) – jchevali Apr 13 '18 at 17:54
  • 1
    here's where I am so far - which seems to pull the domain minus the .com piece: scan(substr(email,index(email, "@")),1) – max Apr 13 '18 at 17:59
  • Can you try substr(email,1+findw(email,"@")) – jchevali Apr 13 '18 at 18:02