Yes, you can put a CHOOSE function inside another. If you are only doing this choice a few times, then it doesn't matter which conditional statements you use, and I'd choose the IF-THEN because it is easier to read. If this is going to be inside a big loop, then you might want to compare the performance by timing the computations. See Remove or keep: Which is faster? - The DO Loop or Chapter 15 of Statistical Programming with SAS/IML Software. Regarding your nested CHOOSE construction, you are missing a final 'else'. What happens if Line^='PP'? It should read: Guar = choose(Line = 'PP', choose(...), SOMEVALUE ); A trick that I like to use is to precompute the nested values so that the nested CHOOSE functions aren't so hard to read. Something like this might be helpful if you 'choose' to use nested CHOOSE functions: /* possible results */ R1 = round(App # Level * .65, .1); R2 = round(App # Level * .70, .1); R3 = round(App # Level * .60, .1); A = choose(option = 'PT', R2, R3); B = choose(option = 'PF', R1, A); Guar = choose(Line = 'PP', B, SOMEVALUE);
... View more