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;
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 25. 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.