Hello guys,
I working on coding for cancer mortality and lung cancer deaths. My code is shown below.
In the code, I want rdeath to represent the death rate per 10,000 person-years (PY). and rcancerdeath and rlungdeath to represent the cancer and lung cancer death rate per 10,000PY respectively. I've struggled to use an array and a do over for this. Can anyone help me check the code?
Data me; set sc_cancer_surveillance;
Array ab ndeath ncancerdeath nlungdeath ;
Array cd rdeath rcancerdeath rlungdeath;
do over cd;
rdeath=ndeath/person_years;
rcancerdeath=ncancerdeath/person_years;
rlungdeath= nlungdeath/person_years;
end;
run;
Please see the initial table that I got and I want to calculate the rates in person-years,
Obs | Smoking | Person_years | Ndeath | Ncancerdeath | Nlungdeath |
1 | 0 | 4200 | 900 | 150 | 39 |
2 | 1 | 5210 | 1100 | 200 | 12 |
Data me;
input Smoking Person_years Ndeath Ncancerdeath Nlungdeath;
Array ab ndeath ncancerdeath nlungdeath ;
Array cd rdeath rcancerdeath rlungdeath;
do over cd;
rdeath=ndeath/person_years
rcancerdeath=ncancerdeath/person_years;
rlungdeath=nlungdeath/person_years;
end;
cards;
0 4200 900 150 39
1 5210 1100 200 12
;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.