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

Answers were Sorted based on User's Feedback



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

Answer / juan

SELECT statement can do logical test. A SELECT statement
provides an alternative to a series of IF and ELSE IF
statements. It is usually more efficient than IF-THEN/ELSE,
especially if you are recoding a variable into a large
number of categories.

Is This Answer Correct ?    7 Yes 0 No

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

Answer / venkatesh.layam

when ever we wre do the task on puarticular variable select
works efficiently than if then else
And it will check immideatly and occupies less space.
it will give good shape out for data.

Is This Answer Correct ?    6 Yes 0 No

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

Answer / gangadhar

IF STATEMENT IS MAINLY USED FOR SUBSETTING OF DATA.IN THE
SAME WAY SUBSETTING IN SQL SELECT STATEMENT IS USED.

Is This Answer Correct ?    2 Yes 2 No

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

Answer / prakask

i think select statements are used when we are using 1
condition to compare with several conditions

Is This Answer Correct ?    2 Yes 2 No

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

Answer / sonu

The SELECT statement begins a SELECT group. SELECT groups contain WHEN statements that identify SAS statements that are executed when a particular condition is true. Use at least one WHEN statement in a SELECT group. An optional OTHERWISE statement specifies a statement to be executed if no WHEN condition is met. An END statement ends a SELECT group.
Null statements that are used in WHEN statements cause SAS to recognize a condition as true without taking further action. Null statements that are used in OTHERWISE statements prevent SAS from issuing an error message when all WHEN conditions are false.
Using Select-When improves processing efficiency and understandability in programs that needed to check a series of conditions for the same variable.
Use IF-THEN/ELSE statements for programs with few statements.
Using a subsetting IF statement without a THEN clause could be dangerous because it would process only those records that meet the condition specified in the IF clause.

Is This Answer Correct ?    0 Yes 0 No

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

Answer / 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

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

Answer / kumarrd

when ever we want check with more than condition we may use
if condition rather than select one

Is This Answer Correct ?    1 Yes 7 No

Post New Answer

More SAS Interview Questions

explain the difference between proc means and proc summary?

0 Answers  


Explain the special input delimiters used in sas programming.

0 Answers  


Mention common programming errors committed in sas ?

0 Answers  


data data1; input dt account; format dt date9.; cards; 1745 1230 1756 1120 1788 1130 1767 1240 ; data data2; input startdt enddt total; format startdt date9. enddt date9.; cards; 1657 1834 12300 1557 1758 16800 1789 1789 12300 1788 1345 12383 1899 1899 13250 ; proc sql; create table data3 as select * from data1 as x left join data2 as y on x.dt>=y.startdt and x.dt<=y.enddt; quit; Here, we are getting cartision product. But,I want left join report consisting of this program. It should not get duplicate values. you can modify the program also.

0 Answers  


how to intersect the tables by using PROC MIXED?

1 Answers   CitiGroup,


What are the statements in proc sql?

0 Answers  


what is sas enterprise intelligence architecture? : Sas-bi

0 Answers  


What is the role of unrestrictive users? : sas-grid-administration

0 Answers  


i have a dataset with var1,var2,var3; i want to upload the titles for the variables . How can we?

1 Answers   GSK,


What is proc sort?

0 Answers  


How can a SAS WEB REPORT STUDIO USER identify which report tabs they have been permitted without entering the SAS WEB REPORT STUDIO

2 Answers   TCS,


To what type of programms have you used scratch macros?

0 Answers   Novartis,


Categories