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;
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: