Hi,
I am fairly new to SAS and I am trying to see how I can write a code to solve the following:
This is a snapshot of my data:
pid grade Disease
15 1 thrombocytopenia
1 2 arrhythmia
1 2 arrhythmia
3 1 tachycardia
3 3 arrhythmia
3 1 arrhythmia
4 1 tachycardia
4 1 arrhythmia
4 1 arrhythmia
4 1 arrhythmia
5 1 tachycardia
5 3 tachycardia
5 1 arrhythmia
6 1 arrhythmia
6 1 arrhythmia
6 3 tachycardia
What I want to do is for every unique disease, all the pids that correspond to it, I just extract the highest grade per pid for that disease. Eg. pid 3 has arrhythmia which has 2 grades (1,3). So I only want to keep grade 3 for this pid. If there is only 1 grade for the pid, I keep that. I create a new dataset based on this rule.
From this new dataset, I create a table that has disease as rows and columns as grade. For each disease I get the total number of pids for each grade.
Many thanks,
M
I am fairly new to SAS and I am trying to see how I can write a code to solve the following:
This is a snapshot of my data:
pid grade Disease
15 1 thrombocytopenia
1 2 arrhythmia
1 2 arrhythmia
3 1 tachycardia
3 3 arrhythmia
3 1 arrhythmia
4 1 tachycardia
4 1 arrhythmia
4 1 arrhythmia
4 1 arrhythmia
5 1 tachycardia
5 3 tachycardia
5 1 arrhythmia
6 1 arrhythmia
6 1 arrhythmia
6 3 tachycardia
What I want to do is for every unique disease, all the pids that correspond to it, I just extract the highest grade per pid for that disease. Eg. pid 3 has arrhythmia which has 2 grades (1,3). So I only want to keep grade 3 for this pid. If there is only 1 grade for the pid, I keep that. I create a new dataset based on this rule.
From this new dataset, I create a table that has disease as rows and columns as grade. For each disease I get the total number of pids for each grade.
Many thanks,
M