BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Neff
Fluorite | Level 6

I have this large data set comprising of over 1000 subjects and about 3000 variables which are ICD9 codes (Dx1- Dx3000). 

Dx represents the ICD diagnosis codes for each visit and is represented here as  1-4

My dataset looks similar to this:

 

 Q.JPG

 

I would like to get the distinct disease count for each subject.

For example: subject 1 has 4 visits but 3 distinct diagnosis.

                      subject 2 has 4 visits and 4 distinct diagnosis

 

Thanks.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

1. proc transpose

2. proc freq by id

View solution in original post

4 REPLIES 4
Neff
Fluorite | Level 6

I have this large data set comprising of over 1000 subjects and about 3000 variables which are ICD9 codes (Dx1- Dx3000). 

Dx represents the ICD diagnosis codes for each visit and is represented here as  1-4

My dataset looks similar to this:

 

 Q.JPG

 

I would like to get the distinct disease count for each subject.

For example: subject 1 has 4 visits but 3 distinct diagnosis.

                      subject 2 has 4 visits and 4 distinct diagnosis

 

Thanks.

 

 

novinosrin
Tourmaline | Level 20

1. proc transpose

2. proc freq by id

PGStats
Opal | Level 21
proc transpose data=myData out=codes;
by id;
var dx1-dx3000;
run;

proc sql;
create table counts as
select id, count(distinct col1) as nbCodes
from codes
group by id;
quit;

(untested)

 

PG
Neff
Fluorite | Level 6

Thank you so much!! Just what I needed and it worked perfectly well

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2303 views
  • 0 likes
  • 3 in conversation