DATA WORK.Have;
FORMAT emailaddr $50.;
INFORMAT emailaddr $50.;
INPUT emailaddr;
CARDS;
AdamApple@gmail.com
BillBobington@yahoo.com
ChuckCooper@hotmail.com
;
run;
data edomain;
set have;
dom=substr(emailaddr,findc(emailaddr,'@'));
run;
hi how to extract domain name from email using proc sql
length dom $ 64;
dom=scan(emailaddr,2,'@');
proc sql;
create table edomain as
select *, scan(emailaddr, 2, '@') as dom length=50
from have;
quit;
How to get same domain emails count in sas
@BrahmanandaRao wrote:
How to get same domain emails count in sas
Please describe the problem in more detail. Please use complete sentences.
data emails;
input emails$ 50.;
datalines;
xxxxxxxxx@gmail.com
xxxxxxx@gmail.com
xxxxxxxx@outlook.com
xxxxxx@outlook.com
xxxx@gmail.com
;
run;
proc sql;
create table email_domain as
select *,scan(emails,-2 ,'@.') as domain
from emails;
quit;
proc sql;
select domain, count(domain) from email_domain
group by domain;
quit;
i want to count same domain names in email address any easy approch other than my code
You can combine both SQL queries into one:
proc sql;
create table email_domain as
select scan(emails,-2 ,'@.') as domain, count(*) as count
from emails
group by domain;
quit;
If the newly created variable had the same name as one contained in the input datasets, use the keyword CALCULATED in the GROUP BY clause.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.