BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Prasad84
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

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

4 REPLIES 4
Reeza
Super User

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


 

ChrisNZ
Tourmaline | Level 20

I agree with @Reeza.

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

where VAR between 'A' and 'B';

Prasad84
Fluorite | Level 6
I agree as where filters data before entering into PDV, So Where is more
efficient.

Thanks.
ChrisNZ
Tourmaline | Level 20

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.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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