Format(Sum(Val(IIf([dataset1].[Var1]=0,0,IIf([dataset1].[var2]=0,1,IIf([dataset1].[var1] Is Null Or [dataset1].[var2] Is Null,0,IIf(Abs([dataset1].[var1]/[dataset1].[var2])>=1,1, IIf(Abs([dataset1].[var1]/[dataset1].[var2])<1,Abs([dataset1].[var1]/[dataset1].[var2])))))))),"Fixed") AS SCORE For reference it doesn't look like there is a false statement in the iif statements so I am expecting that false in this case would report as missing, but I could be wrong. Converts to proc sql; create table ??? as select ID, (sum(Case when dataset1.var1 = 0 then 0 when dataset1.var2 = 0 then 1 else . end), (case when dataset1.var1=. then 0 when dataset1.var2 = . then 0 else . end), (case when (abs(dataset1.var1/dataset1.var2)) >=1 then 1 else (abs(dataset1.var1/dataset1.var2)) end)) format=(whatever the "Fixed" format is) as score from dataset1 group by ID; quit; The question though that I would need answered before figuring anything else out would be should var1 and var2 be evaluated separately, ie should you be asking if var1 = 1 then 1 else if var1 = 0 then 0 else if var1 = . then 0 or do you want to include both in each of the statements? The easiest way to rewrite this is to say what each of the conditions are (as I understand them) if dataset1.var1 = 0 then 0 if dataset1.var2 = 0 then 1 if dataset1.var1 = . then 0 if dataset1.var2 = . then 0 if abs(dataset1.var1/dataset1.var2) >= 1 then 1 if abs(dataset1.var1/dataset1.var2) < 1 then abs(dataset1.var1/dataset1.var2) write a case statement for each of these (similar to what I wrote earlier including the else (value) end statements), put a sum statement outside of all of the case statements, and group by the unique ID. This should give you the same report values as long as you specify the variables in the same way.
... View more