Hi ,
is it possible to display role variable after removing duplicates by using PROC SQL? any suggestion, Thanks in advance.
data demo;
input pid role$;
cards;
101 Hr
102 deveolper
103 analyst
101 admin
;run;
proc sql;
select distinct(pid) from demo; quit;
proc sql;
select pid, role, monotonic() as help
from demo
group by pid
having help = min(help)
;
quit;
run;
Test if you can achieve your goal with the code above. For some background read: https://communities.sas.com/t5/SAS-Communities-Library/MONOTONIC-function-in-PROC-SQL/ta-p/475752.
This seems like an incomplete problem description.
Which of the two values of ROLE for PID=101 should go into the output? To ask the question in a more general way, when there are multiple values of ROLE for a given PID, which of these records should go into the output?
Why use SQL?
proc sort data=demo out=want nodupkey;
by pid;
run;
proc print data=want;
run;
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.