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:
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.
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:
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. proc transpose
2. proc freq by id
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)
Thank you so much!! Just what I needed and it worked perfectly well
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.
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.