BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8

 

 

 

Hello,

Here below I have a column called EMAIL

Of all the emails we wanted to check how many times gmail was wrongly entered....

Since GMAIL starts with the letter "G" we can take all the words starting with letter G after @ in the email adress??????

 

HAVE:

apple@gmail.com

buffalo@gmail.com

cat@gunail.com

dog@GMAI.COM

elephant@gmail.con

goat@yahoo.com

horse@hotmail.com

kangaroo@gnail.com

horse@gmi.com

 

WANT:

gmail.com    2

gunail.com   1

GMAI.COM   1

gmail.con      1

gnail.com      1

gmi.com       1

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

I will suggest that limiting your search to @g is insufficient. You may well have enteries like Johh@jmail.com or John@fmail.com or ...

 

I might be tempted to do something like:

data have;
   length email $40.;
   input email;
   isp =upcase(scan(email,2,"@"));
   distance = complev('gmail.com',isp,'i');
datalines;
apple@gmail.com
buffalo@gmail.com
cat@gunail.com
dog@GMAI.COM
elephant@gmail.con
goat@yahoo.com
horse@hotmail.com
kangaroo@gnail.com
horse@gmi.com
john@tmail.com
john@jmail.com
;

proc tabulate data=have;
   class distance isp;
   table distance*isp,n;
run;

The "distance" value when small means the spelling is "close" to Gmail.com.

 

Note that I did add in couple of other possibly typos.

View solution in original post

2 REPLIES 2
LinusH
Tourmaline | Level 20
Combine scan and substr functions.
Data never sleeps
ballardw
Super User

I will suggest that limiting your search to @g is insufficient. You may well have enteries like Johh@jmail.com or John@fmail.com or ...

 

I might be tempted to do something like:

data have;
   length email $40.;
   input email;
   isp =upcase(scan(email,2,"@"));
   distance = complev('gmail.com',isp,'i');
datalines;
apple@gmail.com
buffalo@gmail.com
cat@gunail.com
dog@GMAI.COM
elephant@gmail.con
goat@yahoo.com
horse@hotmail.com
kangaroo@gnail.com
horse@gmi.com
john@tmail.com
john@jmail.com
;

proc tabulate data=have;
   class distance isp;
   table distance*isp,n;
run;

The "distance" value when small means the spelling is "close" to Gmail.com.

 

Note that I did add in couple of other possibly typos.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 882 views
  • 2 likes
  • 3 in conversation