WHERE vs IF Statements

From sasCommunity

Jump to: navigation, search

Contents

[edit] Title

WHERE vs. IF Statements: Knowing the Difference in How and When to Apply

[edit] Author

Sunil Gupta, Sunil.Gupta@Quintiles.com

- E-mail Sunil to be included on his e-mail distribution list

More articles and books by Sunil Gupta.

[edit] Abstract

When programming in SAS, there is almost always more than one way to accomplish a task. Beginning programmers may think that there is no difference between using the WHERE statement and the IF statement to subset your data set. Knowledgeable programmers know that depending on the situation, sometimes one statement is more appropriate than the other. For example, if your subset condition includes automatic variables or new variables created within the DATA step, then you must use the IF statement instead of the WHERE statement. This paper shows you how and when to apply the WHERE and IF statements to get correct and reliable results. It also reviews the similarities as well as the differences between these two SAS programming approaches. Note that this paper does not focus on comparing the performance differences between the WHERE and IF statements.

[edit] Download Summary Sheet, SAS Paper and Technical Tip

Paper (PDF)

Summary Sheet (DOC)

WHERE vs. IF Statements: Knowing the Difference in How and When to Apply (SAS Usage Note 24286).


More information on Sharpening Your SAS Skills.

Personal tools