楼主: MiSH2HK
7014 5

[问答] SAS Adv 第18题,求解!!!! [推广有奖]

  • 0关注
  • 1粉丝

VIP1

大专生

36%

还不是VIP/贵宾

-

威望
0
论坛币
2022 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
382 点
帖子
35
精华
0
在线时间
39 小时
注册时间
2015-2-1
最后登录
2016-12-23

楼主
MiSH2HK 发表于 2016-4-27 20:37:29 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Given the SAS data set SASUSER.HIGHWAY:

  Steering Seatbelt Speed Status  Count
  ——– ——– —– ——- —–
  absent   No       0-29  serious    31
  absent   No       0-29  not      1419
  absent   No       30-49 serious   191
  absent   no       30-49 not      2004
  absent   no       50+   serious   216

  The following SAS program is submitted:

  %macro HIGHWAY(Belt=no);     
     proc print data=SASUSER.HIGHWAY;   
        where Seatbelt=\”&Belt\” ;
     run;   
  %mend;     

  %HIGHWAY(Belt=No)   

  How many observations appear in
  the generated report?
A.
0   

B.
2   

C.
3   

D.
5
为什么答案是C 啊,不应该是B 么?


而且运行上段程序在SAS里,显示错误,这是为什么?


1       proc print data=crackman;         where Seatbelt=\"&Belt"\;      run;

                                                         -

                                                         22

                                                         76

ERROR: 解析 WHERE 子句时出现语法错误。


ERROR 22-322: 语法错误,期望下列之一: 名称, 带引号的字符串, 数值常数, 日期时间常数, 缺失值, (, *,

              +, -, :, INPUT, NOT, PUT, ^, ~.


ERROR 76-322: 语法错误,语句将被忽略。


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:observations observation following generated observat following where

沙发
Pennsy 学生认证  发表于 2016-4-28 00:33:40 来自手机
第一句话赋给belt的no是初始值,一旦最后一句调用程序时赋予了belt新的值No,将会覆盖初始值。
ps:如果这时第一句用%let定义了全局变量,则以%let赋的值具有最高优先执行权,具体优先执行规则如下:
%let语句中赋的值〉调用程序时赋的值〉程序开始时赋的初始值

藤椅
七月maranda 发表于 2016-4-28 04:20:30
dingding

板凳
5傻小不点 发表于 2016-4-28 09:29:21
问一下这里的\是起什么作用的?

报纸
rendajingguan01 发表于 2016-4-28 13:19:15
%HIGHWAY(Belt=No)    -----------------  调用的时候赋了值 No,所以答案是 3 条吧。

/    是转义字符 , 所以这个语句 相当于  where Seatbelt=\”&Belt\” ; 相当于 ------------>  where Seatbelt=*No* ;这个条件。

For example, if the variable X contains the values abc, a_b, and axb, the following LIKE operator with an escape character selects only the value a_b. The escape character (/) specifies that the pattern searches for a literal ' _' that is surrounded by the characters a and b. The escape character (/) is not part of the search.

where x like 'a/_b' escape '/';

Without an escape character, the following LIKE operator would select the values a_b and axb. The special character underscore in the search pattern matches any single b character, including the value with the underscore:


where x like 'a_b';

地板
MiSH2HK 发表于 2016-4-28 20:18:53
Pennsy 发表于 2016-4-28 00:33
第一句话赋给belt的no是初始值,一旦最后一句调用程序时赋予了belt新的值No,将会覆盖初始值。
ps:如果这 ...
谢谢!!!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 14:53