Please follow the instructions for posting a useful question.
Thank you.
Note that I've moved and renamed your thread to better reflect the topic and find an answer.
The easiest way is either PROC FREQ or PROC SQL.
Assuming the diagnosis code and diagnosis description align, ie one diagnosis only matches one diagnosis description and they are the same over time.
Here's one way:
proc freq data=have noprint;
table EmpID*DiagnosisCode*DiagnosisDescription / out=distinct_diagnosis_per_emp;
run;
Can I write sql query like this?
Proc sql;
select distinct EmpID, DiagnosisCode, DiagnosisDescription from Diag_tbl;
Saawan
May be without EmpID unless you want the distinct list per EmpID. Else: As long as you can be sure that a code has always the exactly same description things should work.
yup!! Thank you for the reply.
You can, but that will give you a list in the output, not a data set. The PROC FREQ generates a data set.
To modify the PROC SQL you could add a CREATE TABLE statement.
How does this work?
This will create a "Unique" table with data.
Proc sql;
create table Unique as
select distinct EmpID, DiagnosisCode, DiagnosisDescription from Diag_tbl;
Thank you Reeza. I appreciate your help.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.