Under what circumstances would you code a SELECT construct
instead of IF statements?

Answer Posted / rushi

When you have a long series of mutually exclusive conditions and the comparison is numeric, using a SELECT group is slightly more efficient than using IF-THEN or IF-THEN-ELSE statements because CPU time is reduced.

The syntax for SELECT WHEN is as follows :

SELECT (condition);
WHEN (1) x=x;
WHEN (2) x=x*2;
OTHERWISE x=x-1;
END;

Example :

SELECT (str);
WHEN ('Sun') wage=wage*1.5;
WHEN ('Sat') wage=wage*1.3;
OTHERWISE DO;
wage=wage+1;
bonus=0;
END;
END;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I have a dataset concat having variable a b & c. How to rename a b to e & f?

585


what are the best practices to process the large data sets in sas programming? : Sas-administrator

546


what is the difference between floor and ceil functions in sas? : Sas-administrator

708


Describe the function and utility of the most difficult SAS macro that you have written?

2035


What do you code to create a macro? : sas-macro

590






How to import multiple xls files into sas. Out of those files, how to get different values from a single variable and how to find number of rows per value type? We can do this using group by for one xls file with proc sql. Was wondering how I can achieve this for multiple files at the same time. Any ideas?

2391


what can you learn from the sas log when debugging? : Sas programming

616


Explain proc univariate?

610


Difference between SAS STATA & SPSS?

685


what is the different between functions and procs that calculate the same simple descriptive statistics? : Sas programming

595


how can you import .csv file in to sas? : Sas programming

642


Have you ever used the SAS Debugger?

1217


what r the job openings SAS for fresher graduates !

2021


Explain by-group processing?

595


what are the scrubbing procedures in sas? : Sas programming

840