Interview Questions   Tutorials   Discussions   Programs   Videos   

SAS - In the SAS Data step what is the difference between the sub setting done by Where and sub setting done by If?




405
views
asked mar September 20, 2014 06:29 AM  

In the SAS Data step what is the difference between the sub setting done by Where and sub setting done by If?


           

1 Answers



 
answered By vishnoiprem   0  
  • WHERE condition requires one of these statements if used within the DATA step. In addition, the variable specified in the WHERE condition must exist in all data sets. * OBS = data set option is compatible with the WHERE statement in SAS version 8.1 and higher. When OBS = is used with the IF statement, SAS first subsets the data set based on the number of observations in the OBS = option and then applies the IF subset condition. When OBS = is used with the WHERE statement, SAS first applies the WHERE subset condition and then restricts the output data set to contain the maximum of observations as specified in the OBS = option. The Colon Modifier (:) works with the IF statement to compare shorter text with longer text. * WHERE condition may be more efficient because SAS is not required to read all observations from the input data set. Results may be different depending on the data sets being merged. In general, use the IF condition to subset the data set after merging the data sets.

There is difference between how SAS handles IF and WHERE conditions. The 'WHERE' condition is applied on data before they enter Program Data Vector (PDV) and in case of 'IF' it is applied after data comes out from PDV. Now, if you have created a variable in the same data step using Where : the created variable will not be applied condition. IF: the created variable will be subjected to the condition applied

flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert