BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
data email;
input email $30.;
datalines;
xxxxxxxxxxx@gmail.com
xxxxxxxxxxxx@outlook.com
xxxxxxxxxxx@gmail.com
xxxxxxxxxxx@gmail.com
;
run;

How to keep only required email address 

example here keep only gmail.com address

3 REPLIES 3
SASKiwi
PROC Star
data email;
input email $30.;
email_provider = scan(email, 2, '@');
datalines;
xxxxxxxxxxx@gmail.com
xxxxxxxxxxxx@outlook.com
xxxxxxxxxxx@gmail.com
xxxxxxxxxxx@gmail.com
;
run;

There are many ways to do this including the SCAN function to read the second word in the string where an ampersand is the delimiter.

BrahmanandaRao
Lapis Lazuli | Level 10

i want output those who have gmail email address in this example data contains three gmail address 

i want complete three gmail address

 

 

Kurt_Bremser
Super User

Just use the SCAN function with "@" as delimiter to get the domain from the email address; if the result of the function is found to be "gmail.com", keep the observation. Can be done in a WHERE statement, WHERE= dataset option, or Subsetting IF, depending on where the subsetting needs to be done.

I will not insult your intelligence by providing this EXTREMELY SIMPLE code. If you cannot solve such a simple issue by now (500+ posts here), then drop your illusion that you'll ever earn money with SAS work.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 986 views
  • 1 like
  • 3 in conversation