This is an interesting example that demonstrates a point that was made in the introduction to this, namely that the SAS System is continually changing and improving. When this example was first written,the title was reversed, with the IN operator being the recommended efficiency method! The way the system processes Boolean expressions was then improved to the point where the use of multiple OR operators is now very efficient, often more so than using an IN operator.
When an IF statement contains a series of comparisons separated by OR operators, as soon as a hit is made, no further tests are done.This example also demonstrates that you may very well want to use an inefficient coding method when you are not in a limited resource production environment and where the relative importance of ease of coding (the IN operator) outweighs efficiency considerations.
Example – INEFFICIENTDATA NEW;
Just as you arranged the order of IF-THEN/ELSE statements in the previous example, you can also arrange the order of the IN list in decreasing probability of inclusion.So, if groups Z and C are the most common, you would put them at the front of the list:IF GROUP IN ( ' Z ' , ' C ' , ' A ' , ' E ' ) ;
The IN operator can also be used with numeric variables. For example,to print only observations corresponding to ID's 1, 5, and 13, you write:PROC PRINT DATA=OLD;
Even though the IN operator is a very useful SAS feature, the following code may be more efficient than the preceding.
Example – EFFICIENTDATA NEW;
Although this program requires more effort to write, it runs faster than the less efficient example.Once again, you should order the OR list in order of decreasing probability of occurrence for absolute maximum efficiency.
SAS Programming Related Tutorials
|SASS (Syntactically Awesome Style sheets) Tutorial||R Programming language Tutorial|
SAS Programming Related Interview Questions
|Logistics Interview Questions||SAS Programming,SQL server Interview Questions|
|Clinical SAS Interview Questions||SASS (Syntactically Awesome Style sheets) Interview Questions|
|SQL Server Analysis Services (SSAS) Interview Questions||R Programming language Interview Questions|
|SAS DI Interview Questions||Advanced SAS Interview Questions|
|Base Sas Interview Questions||SAS Macro Interview Questions|
|Clinical Data Management Interview Questions|
Sas Programming Tutorial
Input And Infile
Set, Merge, And Update
Table Lookup Tools
Proc Means And Proc Uimivariate
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.