I have a piece of my program that has some nested if-then statements. I read in Rick Wicklin's "Statistical Programming with SAS/IML Software" that you should use the choose function when you are assigning values based on certain criteria. I was wondering if the choose function is always the more efficient way since I would be putting choose functions within choose functions. I know it cuts down on the amount of code written, but is there a processing time difference? An example of my code is below. Any help is appreciated. Thank you!
PP_ind = loc(Line = 'PP');
if ncol(PP_ind) > 0 then do;
Guar[PP_ind] = round(App[PP_ind] # Level * .60, .1);
PP_PF_ind = loc(Line = 'PP' & Option = 'PF');
if ncol(PP_PF_ind) > 0 then
Guar[PP_PF_ind] = round(App[PP_PF_ind] # Level * .65, .1);
PP_PT_ind = loc(Line = 'PP' & Option = 'PT');
if ncol(PP_PT_ind) > 0 then
Guar[PP_PT_ind[ = round(App[PP_PT_ind] # Level * .70, .1);
end;
Proposed method using the choose function - not sure if it is the correct syntax because I am getting an error: "ERROR: The arguments to the built-in function are invalid. (444, 22)"
Guar = choose(Line = 'PP', choose(option = 'PF', round(App # Level * .65, .1), choose(option = 'PT', round(App # Level * .70, .1), round(App # Level * .60, .1))))
Maybe my question should be - "Is it possible to put a choose function inside of another choose function?"