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

Suppose a person can belong to any of the RACEs with the probability of PROB_RACE. And marginal probability of dying in years 1 to 3 is given(marginal survival will be 1-PROB_DYING):

RACEPROB_RACEPROB_DYING_YR1PROB_DYING_YR2PROB_DYING_YR3
A0.260.10.20.3
B0.350.160.250.45
C0.230.230.340.17
D0.160.180.170.14

 

So the person belonging to RACE A will have a probability of survival after 3 years, call it SURV3_A = (1-0.1)*(1-0.2)*(1-0.3).

Similarly, SURV3_B=(1-0.16)*(1-0.25)*(1-0.45) and so on...

And a random person will have a probability of survival after 3 years as : PROB_A*SURV3_A+PROB_B*SURV3_B+PROB_C*SURV3_C+PROB_D*SURV3_D.

I was thinking of a generalization to calculate probability of survival of any random person after 'T' years when there can be 'N' possible RACEs.

 

I can think of taking one row at a time,using CUPROD, then summing across columns which seem inefficient, so wondering if any easy way?

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Just want to add that it is considered bad etiquette to post the same question twice and solicit advice in two separate threads.

 

I answered in the other thread. Good luck with your problem. 

View solution in original post

8 REPLIES 8
Reeza
Super User

Implementing your base formula is trivial in a data step. Can you show what you expect as the final, final output, assuming this is the input? I want to ensure there's nothing I'm missing before taking a further look or providing any code.

 


@thepushkarsingh wrote:

Suppose a person can belong to any of the RACEs with the probability of PROB_RACE. And marginal probability of dying in years 1 to 3 is given(marginal survival will be 1-PROB_DYING):

RACE PROB_RACE PROB_DYING_YR1 PROB_DYING_YR2 PROB_DYING_YR3
A 0.26 0.1 0.2 0.3
B 0.35 0.16 0.25 0.45
C 0.23 0.23 0.34 0.17
D 0.16 0.18 0.17 0.14

 

So the person belonging to RACE A will have a probability of survival after 3 years, call it SURV3_A = (1-0.1)*(1-0.2)*(1-0.3).

Similarly, SURV3_B=(1-0.16)*(1-0.25)*(1-0.45) and so on...

And a random person will have a probability of survival after 3 years as : PROB_A*SURV3_A+PROB_B*SURV3_B+PROB_C*SURV3_C+PROB_D*SURV3_D.

I was thinking of a generalization to calculate probability of survival of any random person after 'T' years when there can be 'N' possible RACEs.

 

I can think of taking one row at a time,using CUPROD, then summing across columns which seem inefficient, so wondering if any easy way?


 

 

thepushkarsingh
Quartz | Level 8
I understand creating 3 more variables(cumulative product, so the 1st column will remain same, 2nd will be product till 2 years, 3rd will be for 3 years) will not be an issue and with another proc sql or retain statement sum of column and final sum will also be easy. But it'll take a lot of text and more than one data/proc steps(for me). For significantly large number of years, I was thinking of any more efficient way.
Reeza
Super User
Still need the expected output to help you here. Or if you already have a solution and need it more efficient, perhaps post the code you have already.
thepushkarsingh
Quartz | Level 8

Hi @Reeza, apologies for earlier responses. I have following matrix, X:

0.10.20.3
0.160.250.45
0.230.340.17
0.180.170.14

 

(1-X) will be:

0.90.80.7
0.840.750.55
0.770.660.83
0.820.830.86

 

And I need cumulative product at each row like:

0.90.720.504
0.840.630.3465
0.770.50820.421806
0.820.68060.585316

 

Then I need column wise sum like:

3.332.53881.857622

 

And in the end, a row sum :

7.726422

 

I was superexcited with @Rick_SAS's solution which suggested use of (1-X)[,#], but it only gives me final column. Any suggestion?

Thanks a lot in advance.

Rick_SAS
SAS Super FREQ

Just want to add that it is considered bad etiquette to post the same question twice and solicit advice in two separate threads.

 

I answered in the other thread. Good luck with your problem. 

thepushkarsingh
Quartz | Level 8

I am very sorry, while I was posting further information in your solution, I saw the section where it said 'If you need further help post a new question', so I marked the original post as solved and posted it again separately. I thought it would be disrespectful if I don't tell you about my inquiries, so I posted there too. I didn't mean to disrespect, which seemingly I did eventually.

Apologies to both @Rick_SAS and @Reeza.

Rick_SAS
SAS Super FREQ

I accept your apology, but let me clarify that the issue isn't that cross-posting is disrespectful. When there are two threads, it is hard for experts to work from the same information and to build a program that solves your problem. It will also be difficult for someone who has a similar question in the future to solve their problem by consulting these pages. There are ways to merge the two threads into one, but they have diverged so much that I'm not sure it would be helpful.  I have a hard time understanding these threads even though I was involved in writing one of them.

 

I would like to encourage you to revisit the "accepted solution" that you marked in the other thread. After you marked my initial response as correct, you provided extra information and I posted additional programs. I don't know whether the later solutions are better, but please mark the answer that best resolves your problem.

 

 

thepushkarsingh
Quartz | Level 8

Thanks for understanding. I'll not repeat same mistake.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 8 replies
  • 1557 views
  • 2 likes
  • 3 in conversation