BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ChuksManuel
Pyrite | Level 9

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

1 ACCEPTED SOLUTION

Accepted Solutions
blueskyxyz
Lapis Lazuli | Level 10
sorry, please add semicolon in this row: rdeath=ndeath/person_years;

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;


View solution in original post

3 REPLIES 3
blueskyxyz
Lapis Lazuli | Level 10
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;
blueskyxyz
Lapis Lazuli | Level 10
sorry, please add semicolon in this row: rdeath=ndeath/person_years;

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: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 633 views
  • 0 likes
  • 2 in conversation