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

While doing practice exams for the Advanced programmer certification I encountered the following question:

 

------------------

This question will ask you to provide a segment of missing code.

 

The following  SAS program is submitted:

 

proc sql;

select a.name, a.sal, a.dept, b.maxsal

from EMP a, 

<insert code here>

where a.dept=b.maxsal

What segment of code will successfully run an in-line view?

 

A)

 ( create dept, max(sal) as maxsal
from EMP
group by dept) b

B)

create ( dept, max(sal) as maxsal
from EMP
group by dept) b

 

C)

(select dept, max(sal) as maxsal
from EMP
group by dept) b

 

D)

select ( dept, max(sal) as maxsal
from EMP
group by dept) b

-----------------------------

 

My intuition here says C, since the SELECT statement always seems to be made inside the parenthesis. But the correct answer

seems to be D. Am I missing something and in that case what?

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @Syntas_error,

 

Don't let typos in prep guides (or wherever D was stated to be the correct answer) confuse you. Of course, only C is correct. You can test it with a simple example (e.g. a single obs. with all variables 0).

View solution in original post

6 REPLIES 6
FreelanceReinh
Jade | Level 19

Hi @Syntas_error,

 

Don't let typos in prep guides (or wherever D was stated to be the correct answer) confuse you. Of course, only C is correct. You can test it with a simple example (e.g. a single obs. with all variables 0).

Syntas_error
Quartz | Level 8

"sigh"

 

I know for a fact that question is part of the actual exam, there's a very realy chance I will have to "memorize" a number of these typos which feels incredibly backwards ^^

PGStats
Opal | Level 21
where a.dept=b.maxsal

?? The authors of these questions are very creative indeed Smiley Very Happy

PG
Syntas_error
Quartz | Level 8

So only the inner query (that is to say the in-line view) executes when the outer query fails?

FreelanceReinh
Jade | Level 19

@Syntas_error wrote:

So only the inner query (that is to say the in-line view) executes when the outer query fails?


If you asked me, I'd rather say: The inline view can be thought of as a virtual table which is created "on the fly" and then immediately used in the implicit join that constitutes the outer query. The result is the same as if that table had been created physically as a named SAS dataset in a preliminary PROC SQL step (using the code of the inline view).

 

If the outer query fails because of, say, a non-existing variable or table or a syntax error, this will be noticed during compilation already, so the inner query will not be executed in this case.

DMIN
Fluorite | Level 6
C is correct for sure. The answers given are not always correct sometimes, i know this when preparing for the SAS certification exams.

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1117 views
  • 7 likes
  • 4 in conversation