DATA Step, Macro, Functions and more

SAS multiple choice efficiency question

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

SAS multiple choice efficiency question

[ Edited ]

Key says answer is option A, But according to my knowledge its for range of character variables so( Option D).

Please anyone clarify.

Thanks

 

 

Given a SAS data set with the following characteristics:
200 million observations
300 variables
Compressed
Resides on a network location
A SAS DATA Step program is written that will retrieve 20% of the data using a search based on a range of a character variable.
Which type of statement is the best choice to minimize computer resource utilization when subsetting this data?
A. KEEP/DROP
B. WHERE
C. CASE
D. IF/THEN/ELSE


Accepted Solutions
Solution
‎03-23-2018 01:29 AM
PROC Star
Posts: 2,231

Re: SAS multiple choice efficiency question

I agree with @Reeza.

Supposing the question means what it seems to imply, the answer would be

where VAR between 'A' and 'B';

View solution in original post


All Replies
Super User
Posts: 22,874

Re: Base SAS

You need a new source for questions. You get what you pay for sometimes. 

 

A is not correct and D would not be my guess. 

 


@Prasad84 wrote:

Key says answer is option A, But according to my knowledge its for range of character variables so( Option D).

Please anyone clarify.

Thanks

 

 

Given a SAS data set with the following characteristics:
200 million observations
300 variables
Compressed
Resides on a network location
A SAS DATA Step program is written that will retrieve 20% of the data using a search based on a range of a character variable.
Which type of statement is the best choice to minimize computer resource utilization when subsetting this data?
A. KEEP/DROP
B. WHERE
C. CASE
D. IF/THEN/ELSE


 

Solution
‎03-23-2018 01:29 AM
PROC Star
Posts: 2,231

Re: SAS multiple choice efficiency question

I agree with @Reeza.

Supposing the question means what it seems to imply, the answer would be

where VAR between 'A' and 'B';

Occasional Contributor
Posts: 8

Re: SAS multiple choice efficiency question

I agree as where filters data before entering into PDV, So Where is more
efficient.

Thanks.
PROC Star
Posts: 2,231

Re: SAS multiple choice efficiency question

Ha, that's the theory. If only things were that simple.

 

In fact WHERE clauses are a bit faster than IF tests when simple (equality or inequality) value validations are performed.

But they are slower when functions are used.

 

 



16741  data TEST;
16742    do I=1 to 1e8;
16743      output;
16744    end;
16745  run;


16746  data _null_;
16747    set TEST;
16748    if I=1;
16749  run;

      real time           5.21 seconds


16750  data _null_;
16751    set TEST;
16752    where I=1;
16753  run;

      real time           4.73 seconds


16754  data _null_;
16755    set TEST;
16756    if round(I)=1;
16757  run;

      real time           8.40 seconds


16758  data _null_;
16759    set TEST;
16760    where round(I)=1;
16761  run;
real time 16.07 seconds

 

In this simple test on my PC, WHERE is 10% faster than IF for an equality validation, but 100% slower if a function is used.

 

 

I only uncovered these variations last year, and will have to update the third edition of my book.

 

It looks as if functions compiled as part of the data step are more efficient than functions that process the data buffer before the PDV is loaded.

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 153 views
  • 5 likes
  • 3 in conversation