- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-31-2020 02:42 AM
(4842 views)
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
6 REPLIES 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
length dom $ 64;
dom=scan(emailaddr,2,'@');
--
Paige Miller
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sql;
create table edomain as
select *, scan(emailaddr, 2, '@') as dom length=50
from have;
quit;
PG
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How to get same domain emails count in sas
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@BrahmanandaRao wrote:
How to get same domain emails count in sas
Please describe the problem in more detail. Please use complete sentences.
--
Paige Miller
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.