Dear @andreas_lds I ll explain it briefly in a point wise Please let me know where you need more clarification. Point 1 : From the Master (Have) table, I fetched MIN record_date (First record_date) values for each IDs. (Get the master table from above post) So I get 6 IDs and their first record_date, CRE values are printed in my new table (Want). Point 2 : In Want table I have ID(6 IDs), sex, Age, fv_date(First Record_date), fv_Cre( CRE value on First Record_date) (Sex, Age - Updated in Want from another table). Point 3: Now I have to calculate EPI value in Want table using the given formula. (Forget about the EPI stages now that might confuse you) data Formula;
set Want;
if (fv_cre le 0.7 and sex='F') then
do;
EPI = 144*(fv_cre/0.7)**-0.329 * 0.993**Age;
end;
if (fv_cre gt 0.7 and sex='F') then
do;
EPI = 144*(fv_cre/0.7)**-1.209 * 0.993**Age;
end;
if (fv_cre le 0.9 and sex='M') then
do;
EPI = 141*(fv_cre/0.9)**-0.411 * 0.993**Age;
end;
if (fv_cre gt 0.9 and sex='M') then
do;
EPI = 141*(fv_cre/0.9)**-1.209 * 0.993**Age;
end; Once you run this. You will get first record_date EPI value in Want table. Up to here, Want table will be look like : This is what I have done till now. (all First visits) Point 4: Now I need to create a variable of Nxt_CRE_Date , Nxt_CRE, Nxt_EPI in Want table. Again the above procedure follows in Nxt series but, the loop I need here is : It should cross check the 2nd Record_date CRE value, then calculate EPI - If that EPI result is < 60 then It should print all corresponding values(Date,CRE,EPI) in Nxt_series, Incase that EPI result is > 60 it should move and cross check the 3rd Record_date, CRE, and calculate EPI and make sure that EPI < 60 then print on same columns. If EPI not met < 60 it go to another visit. This loop goes until the condition met the last Record_date.
... View more