简体   繁体   English

SAS PROC SQL验证

[英]SAS PROC SQL VALIDATE

I wonder may I ask a question in terms of "PROC SQL VALIDATE" as follows: 我想知道我是否可以按照以下“ PROC SQL VALIDATE”提出问题:

Which statement about the following PROC SQL query is "false"? 关于以下PROC SQL查询的哪条语句为“假”?

    proc sql;
validate
select name label="Country",
rate label="Literacy Rate"
from world.literacy 
where "Asia" =
(select continent 
from world.continents
where literacy.name=
continents.country)
order by 2;

I wonder why the first options below is not "false"? 我想知道为什么下面的第一个选项不是“ false”?

 (a) The query syntax is not valid. 

 (b) The outer query must pass values to the subquery 
    before the subquery can return values to the outer 
    query

(c) PROC SQL will not execute this query when it is
    submitted   

(d) After the query is submitted, the SAS log will 
    indicate whether the query has valid syntax

The answer is (d) I was wondering why the query syntax is not valid? 答案是(d)我想知道为什么查询语法无效?

Thank you very much!! 非常感谢你!!

The query that you have posted has a correlated sub-query ( from world.continents ). 您发布的查询具有correlated子查询( from world.continents )。 This sub-query cannot be evaluated independently, but actually depends on the values passed to them by the outer query ( world.literacy ). 该子查询无法独立评估,但实际上取决于外部查询传递给它们的值( world.literacy )。

Let me explain each of the 4 options, 让我解释一下这四个选项,

(a) The query syntax is not valid. - False

No, this is totally valid statement, where we have an outer-query and a sub-query. 不,这是完全有效的语句,其中有一个外部查询和一个子查询。

(b) The outer query must pass values to the subquery before the 
    subquery can return values to the outer query - True

As mentioned on the top, this is what actually happens. 如顶部所述,这是实际发生的情况。

(c) PROC SQL will not execute this query when it is submitted - True

As you can see in the doumentation , a validate statement only checks for the accuracy of a query expression's syntax and semantics without executing the expression. 正如您在doumentation中看到的那样validate语句仅在不执行表达式的情况下检查查询表达式的语法和语义的准确性。

(d) After the query is submitted, the SAS log will 
    indicate whether the query has valid syntax - True

The same documentation also mentions that validate statement writes a message in the SAS log that states that the query is valid. 同一文档还提到了validate语句在SAS日志中写入一条消息,指出该查询有效。 If there are errors, then validate writes error messages to the SAS log. 如果存在错误,则validate将错误消息写入SAS日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM