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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.