Hi, I need help with below.. I need to check and see which id_number(s) have used different names for transactions on the same id_number, I need to see how many different names have been used to process transactions on the same id_number( if same name
Data HAVE
data transactions;
input amount id_number name &:$50. ;
datalines;
100 9006 John
200 9006 Suzan
250 9006 Kurt
1000 8501 Mary
800 8501 Sean
500 7605 Drake
3000 7605 Drake
50000 5605 Solly
;
Data WANT
id_number count_of_different_names_used
9006 3
8501 2
7605 1
5605 1
@DJongman , you want to count distinct names
proc sql;
create table want as
select id_number,
count(distinct name) as count_of_different_names_used
from transactions
group by id_number
order by count_of_different_names_used desc;
quit;
Something like this?
proc sql;
create table want as
select id_number,
count(*) as count_of_different_names_used
from have
group by id_number
order by count_of_different_names_used desc;
quit;
@DJongman , you want to count distinct names
proc sql;
create table want as
select id_number,
count(distinct name) as count_of_different_names_used
from transactions
group by id_number
order by count_of_different_names_used desc;
quit;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: