12-08-2014 10:04 PM
suppose I have the following equation: R = A*B, and B = C/D
and suppose I have the following table:
In the first line I can directly calculate R1 = a1*b1, but in the second line I need to R2 = a2*c2/d2,
so how is it possible to write a code that will choose the right formula depending on the available information?
ps: in case all variables are available, choose the "straightest" method, i.e R=A*B
12-08-2014 11:39 PM
Hi stat@sas, ran your code and it was good, thank you!
Could you please also show me how to achieve the same result using the IF THEN ELSE procedures because if my actual case will have more variables and more complex equations I guess it will be too messy to put everything into a single COALESCE?
12-09-2014 01:29 AM
Since you'll end up hard coding things not necessarily. If you have multiple formulas/conditions I'd probably calculate them all, but then use a coalesce to determine which is the final one to keep. The issue then becomes how to keep your log clean, if that's a requirement.
Need further help from the community? Please ask a new question.