BookmarkSubscribeRSS Feed
9 REPLIES 9
Saawan
Obsidian | Level 7

Thank you.

Reeza
Super User

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;
Saawan
Obsidian | Level 7

Can I write sql query like this?

 

Proc sql;

select distinct EmpID, DiagnosisCode, DiagnosisDescription from Diag_tbl;

 

Saawan

Patrick
Opal | Level 21

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

Saawan
Obsidian | Level 7

yup!! Thank you for the reply.

Reeza
Super User

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. 

Saawan
Obsidian | Level 7

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;

 

Saawan
Obsidian | Level 7

Thank you Reeza. I appreciate your help.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 4294 views
  • 3 likes
  • 4 in conversation