DATA Step, Macro, Functions and more

Find unique values for a diagnosis column

Reply
Occasional Contributor
Posts: 14

Find unique values for a diagnosis column

[ Edited ]

 

 

Super User
Posts: 9,551

Re: Clinical SAS

Please follow the instructions for posting a useful question.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 14

Re: Clinical SAS

Posted in reply to KurtBremser

Thank you.

Super User
Posts: 22,823

Re: Find unique values for a diagnosis column

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;
Occasional Contributor
Posts: 14

Re: Find unique values for a diagnosis column

Can I write sql query like this?

 

Proc sql;

select distinct EmpID, DiagnosisCode, DiagnosisDescription from Diag_tbl;

 

Saawan

Respected Advisor
Posts: 4,541

Re: Find unique values for a diagnosis column

@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.

Occasional Contributor
Posts: 14

Re: Find unique values for a diagnosis column

yup!! Thank you for the reply.

Super User
Posts: 22,823

Re: Find unique values for a diagnosis column

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. 

Occasional Contributor
Posts: 14

Re: Find unique values for a diagnosis column

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;

 

Occasional Contributor
Posts: 14

Re: Find unique values for a diagnosis column

Thank you Reeza. I appreciate your help.

Ask a Question
Discussion stats
  • 9 replies
  • 430 views
  • 3 likes
  • 4 in conversation