BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
data email;
input email $30.;
datalines;
[email protected]
[email protected]
[email protected]
[email protected]
;
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;
[email protected]
[email protected]
[email protected]
[email protected]
;
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.

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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
  • 1916 views
  • 1 like
  • 3 in conversation