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

sas-innovate-2024.png

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.

 

Register now!

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
  • 2084 views
  • 0 likes
  • 3 in conversation