SAS 高级 习题 SQL

1. Which of the clauses in the PROC SQL program below is written incorrectly?

proc sql;

select style sqfeet bedrooms

from choice.houses

where sqfeet ge 800;

a. SELECT

b. FROM

c. WHERE

d. both a and c


Correct answer: a

The SELECT clause in the program is written incorrectly. Columns that are listed in the clause must be separated by commas, not just blanks.


2. How many statements does the program below contain?

proc sql;

select grapes,oranges,

grapes + oranges as sumsales

from sales.produce

order by sumsales;

a. two

b. three

c. four

d. five


Correct answer: a

There are two statements, the PROC SQL statement and the SELECT statement. The SELECT statement contains three clauses.


3. Complete the following PROC SQL query to select the columns Address and SqFeet

from the table List.Size and to select Price from the table List.Price. (Only the

Address column appears in both tables.)

proc sql;

_____________

where size.address = price.address;

from list.size,list.price;

a. select address,sqfeet,price

b. select size.address,sqfeet,price

c. select price.address,sqfeet,price

d. either b or c


Correct answer: b

The SELECT clause lists the columns from both tables to be queried. You must use a prefix with the Address column because it appears in both tables. The prefix specifies the table from which you want the column to be read.


4. Which of the clauses below correctly sorts rows by the values of the columns Price

and SqFeet?

a. order price, sqfeet

b. order by price,sqfeet

c. sort by price sqfeet

d. sort price sqfeet


Correct answer: b

The ORDER BY clause specifies how the rows are to be sorted. You follow the keywords ORDER BY by one or more column names or numbers, separated by commas.


5. Which clause below specifies that the two tables Produce and Hardware be queried?

Both tables are located in a library to which the libref Sales has been assigned.

a. select sales.produce sales.hardware

b. from sales.produce sales.hardware

c. from sales.produce,sales.hardware

d. where sales.produce, sales.hardware


Correct answer: c

In the FROM clause, you list the names of the tables to be queried, separated by commas.


6. Complete the SELECT clause below to create a new column named Profit by

subtracting the values of the column Cost from those of the column Price.

select fruit,cost,price,

________________

a. Profit=price-cost

b. price-cost as Profit

c. profit=price-cost

d. Profit as price-cost


7. What happens if you use a GROUP BY clause in a PROC SQL step without a

summary function?

a. The step does not execute.

b. The first numeric column is summed by default.

c. The GROUP BY clause is changed to an ORDER BY clause.

d. The step executes but does not group or sort data.


Correct answer: c

The GROUP BY clause is used in queries that include one or more summary functions. If you specify a GROUP BY clause in a query that does not contain a summary function, your clause is changed to an ORDER BY clause.


8. If you specify a CREATE TABLE statement in your PROC SQL step,

a. the results of the query are displayed, and a new table is created.

b. a new table is created, but it does not contain any summarization that was

specified in the PROC SQL step.

c. a new table is created, but no report is displayed.

d. results are grouped by the value of the summarized column.


Correct answer: c

The CREATE TABLE statement enables you to store your results in a SAS table instead of displaying the query results as a report.


9. Which statement is true regarding the use of the PROC SQL step to query data that is

stored in two or more tables?

a. When you join multiple tables, the tables must contain a common column.

b. You must specify the table from which you want each column to be read.

c. The tables that are being joined must be from the same type of data source.

d. If two tables that are being joined contain a same-named column, then you must specify the table from which you want the column to be read.


Correct answer: d

If you are joining two tables that contain a same-named column, then you must use a prefix to specify the table(s) from which you want the column to be read. Remember that if you join tables that don't contain columns that have matching data values, you can produce a huge amount of output. Be sure to specify a WHERE clause to select only the rows that you want.


10. Which clause in the following program is incorrect?

proc sql;

select sex,mean(weight) as avgweight

from company.employees company.health

where employees.id=health.id

group by sex;

a. SELECT

b. FROM

c. WHERE

d. GROUP BY


Correct answer: b

The table names that are specified in the FROM clause must be separated by commas. Note that you can specify columns in the WHERE clause that are not specified in the SELECT clause.


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

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,657评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,662评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,143评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,732评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,837评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,036评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,126评论 3 410
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,868评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,315评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,641评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,773评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,470评论 4 333
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,126评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,859评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,095评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,584评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,676评论 2 351

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,312评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,442评论 0 23
  • By clicking to agree to this Schedule 2, which is hereby ...
    qaz0622阅读 1,440评论 0 2
  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,448评论 0 13
  • 忙里偷闲去看花 春风蓝天花儿俏 迎春榆梅又结香 朵朵花儿风中舞 独自一人赏美景 却忘世间是与非 唯有香气甘如美 贪...
    白小白说阅读 657评论 2 26