Hello.
I have vital statistics data, and I need to calculate the total number of deaths for each main group and subgroup of causes of death. The causes of death are coded using International Classification of Disease, versions 7 through 10, and each group or subgroup includes codes pooled from these four ICD versions. I’ve written code that labels each subgroup and also assigns labels to the main groups, such as deathcause 1 and deathcause 2. The code calculates the total counts for the subgroups (deathcause 2), and then for the remaining main groups (deathcause 1). However, what I want to achieve now is to compute the total number of deaths for each main group—for example, the total count for deathcause 1, and the total count for deathcause 2.
Thank you!
data orig_data;
input ID $ sex death_cause $ ICD;
datalines;
A 1 A00 10
B 2 A00.1 10
C 2 A00.2 10
D 2 B00 10
C 1 B00.3 10
.
.
.
A 1 A00 9
B 2 A00.1 9
C 1 A00.2 9
D 1 B00 9
C 1 B00.3 9
.
.
.
run;
data new; set orig_data;
IF ICD = 10 then do;
IF "A00" <= substr(death_cause,1,3) <= "A99" then do;
IF substr(death_cause,1,3) in ("A20","A21","A25") then do; deathcause_2=2; end;
Else deathcause_1=1;
end;
...................... IF ICD = 9 then do;
IF "001" <= substr(death_cause,1,3) <= "139" then do;
IF substr(death_cause,1,3) in ("032","033","034") then do; deathcause_2=2; end;
Else deathcause_1=1;
end; .....................
... View more