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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.