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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.