SAS Advanced Programming for SAS 9 — Question 31
Given the following SAS data set ONE:
ONE -
REP COST -
SMITH 200 -
SMITH 400 -
JONES 100 -
SMITH 600 -
JONES 100 -
JONES 200 -
JONES 400 -
SMITH 800 -
JONES 100 -
JONES 300 -
The following SAS program is submitted:
proc sql;
select rep, avg(cost) as AVERAGE
from one
group by rep
having avg(cost) > (select avg(cost) from one);
quit;
Which one of the following reports is generated?
Answer options
- A. REP AVERAGE JONES 200
- B. REP AVERAGE JONES 320
- C. REP AVERAGE SMITH 320
- D. REP AVERAGE
Correct answer: D
Explanation
The correct answer is D because the HAVING clause filters groups based on their average cost being greater than the overall average cost from the dataset. In this case, both JONES and SMITH have average costs that are not greater than the overall average, resulting in no records being returned in the report.