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
How to limit decimal places for variable using proc means?
What are the table names in oracle database...?
If a variable contains letters or special characters, can it be numeric data type?
What is the difference between SAS functions and procedures?
What is program data vector (pdv)?
What is the difference between the proc sql and data step?
What will calendar procedure do?
What is the differnce between SDTM 3.1.2 to 3.1.1 version
what is the basic structure sas administrator? : Sas-administrator
what are the types of interactive display types? : Sas-bi
What is auto call macro and how to create a auto call macro? What is the use of it? How to use it in sas with macros? : sas-macro
what are input dataset and output dataset options? : Sas programming
what is function of retain statment
why is a stop statement needed for the point=option on a set statement? : Sas programming
what is the difference between floor and ceil functions in sas? : Sas-administrator