Hello all, I am a SAS beginner, so please ignore if I made any mistakes in the code. Until now I was using excel to calculate the number of persons and person time of follow up. Now, I build a code in SAS that would give me the same output by just specifying few parameters in the macro. I need help to simplify the program and allow extended periods of follow up time. Below is what I have done: %macro test (y1, y2,y3,rate);
data want;
ny1 = &y1*(1-&rate*0.5);
pyy1 = ny1*0.5+(&y1-ny1)*0.25;
ny2 = &y2*(1-&rate*0.5)+ ny1*(1-&rate);
pyy2 = &y2*(1-&rate*0.5)*0.5+(&y2-&y2*(1-&rate*0.5))*0.25 + ny1*(1-&rate*0.5);
ny3 = &y3*(1-&rate*0.5)+ ny2*(1-&rate);
pyy3 = &y3*(1-&rate*0.5)*0.5+(&y3-&y3*(1-&rate*0.5))*0.25 + ny2*(1-&rate*0.5);
ny4 = ny3*(1-&rate);
pyy4 = ny3*(1-&rate*0.5);
ny5 = ny4*(1-&rate);
pyy5 = ny4*(1-&rate*0.5);
run;
proc print data=want;
run;
%mend test;
%test (20,30,40, 0.06); In the above program, ny1 is the number of persons and pyy1 is the number of person years contributed in the Year 1 . The logic for the first three years keeps changing. From the fourth year onward it remains the same formula. So, for 8th year the formula would be ny8 = ny8*(1-&rate);
pyy8 = ny8*(1-&rate*0.5) I have shared the code for the first five years. But I need for extended periods of time like say 15 years. How can I best simplify my program. Also, I need the output in the below format (Add Cumulative Person years): Year ny1 pyy1 Cumilative PY 1 19.4 9.85 9.85 2 47.336 33.593 43.443 3 83.2958 65.6159 109.0589 4 78.2981 80.797 189.8559 5 73.6002 75.9491 265.805 Thank you very much for all your help!!
... View more