Friday, October 20, 2006

Where or If?

When is it most efficient to use a WHERE statement vs. a subsetting IF statement? The answer is (of course) it depends.

When subsetting from a large dataset, WHERE processing is usually more efficient because WHERE statements are evaluated before an observation is read into the program data vector. Subsetting IF statements test the condition after an observation is read into the program data vector.

However, you cannot use WHERE processing on anything other than a variable value that already exists.

Subsetting IF statements must be used in expressions that use:
• Values from raw data
• Values calculated or assigned during the course of the data step
• Automatic variables created in a data step (ex: first.variable , last.variable, _N_)

WHERE expression examples:
proc print data=work.enrollment;
where district='227913';
run;
proc print data=work.enrollment (where=(birthdate = '01SEP2000'D));
run;

proc sql;
select district, sum(students) as Students
from work.enrollment
where district='227901';
quit;

5 comments:

  1. Anonymous3:30 AM


    Really very nice blog information for this one and more technical skills are improve,i like that kind of post.

    CCNA Training in Chennai

    ReplyDelete
  2. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care.As always, we appreciate your confidence and trust in us..SAP Training in chennai

    ReplyDelete

  3. Thanks a lot for all your valuable article! We are really happy about the your thoughts... SAP Training in chennai

    ReplyDelete
  4. Superb i really enjoyed very much with this article here. Really its a amazing article i had
    ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and
    please keep update like this excellent article.thank you for sharing such a great blog with
    us. expecting for your updation.
    seo company in chennai

    ReplyDelete
  5. Wonderful bloggers like yourself who would positively reply encouraged me to be more open and engaging in commenting. So know it's helpful..
    SEO Company in Chennai
    Digital Marketing Company in Chennai

    ReplyDelete