1.A realtor has two customers. One customer wants to view a list of homes selling for
less than $60,000. The other customer wants to view a list of homes selling for
greater than $100,000.
Assuming the PRICE variable is numeric, which one of the following PRINT
procedure steps will select all desired observations?
A. proc print data = sasuser.houses;
where price lt 60000;
where price gt 100000;
run;
B. proc print data = sasuser.houses;
where price lt 60000 or price gt 100000;
run;
C. proc print data = sasuser.houses;
where price lt 60000 and price gt 100000;
run;
D. proc print data = sasuser.houses;
where price lt 60000 or where price gt 100000;
run;
答案是B 但是我认为A是不是也可以?
2.
The following SAS program is submitted:
data work.test;
Author = 'Agatha Christie';
First = substr(scan(author,1,' ,'),1,1);
run;
Which one of the following is the length ofthe variable FIRST in the output data
set?
A. 1
B. 6
C. 15
D. 200
Answer: D
为什麽答案是D?
3.
The following SAS program is submitted:
data work.test;
Title = 'A Tale of two Cities, Charles j.Dickens';
Word = scan(title,3,' ,');
run;
Which one of the following is the value of the variable WORD in the output data
set?
A. T
B. of
C. Dickens
D. ' ' (missing character value)
Answer: B
为什麽答案是B?
4.
The following SAS DATA step is submitted:
data work.accountting;
set work.department;
length jobcode$ 12;
run;
The WORK.DEPARTMENT SAS data set contains a character variable named
JOBCODE with a length of 5.
Which one of the following is the length of the variable JOBCODE in the output
data set?
A. 5
B. 8
C. 12
D. The length can not be determined as the program fails to execute due to errors.
Answer: A
为什麽答案是A不是C?
5.
The following SAS program is submitted:
data work.staff;
JobCategory= 'FA';
JobLevel= '1';
jobCategory= JobCategory || JobLevel;
run;
Which one of the following is the value of the variable JOBCATEGORY in the
output data set?
A. FA
B. FA1
C. FA 1
D. ' ' (missing character value)
Answer: A
为什麽答案是A不是B或者C?原理是什麽?
谢谢!
求助sas base programming 123题里的几道题~
答案:4 悬赏:30 手机版
解决时间 2021-02-15 23:37
- 提问者网友:雪舞兮
- 2021-02-15 13:05
最佳答案
- 五星知识达人网友:持酒劝斜阳
- 2021-02-15 14:15
1.答案A.等价于:
proc print data = sasuser.houses;
where price gt 100000;
run;
所以不对.
2.SAS是在编译阶段就决定变量的长度的,所以length(first)=length(scan(author,1,' ,')).而在没有其他语句(对变量长度有影响的语句,如length语句等)的情况下,用scan函数赋值的变量默认长度为200(SAS中字符型变量的最长长度)。
3.程序中scan函数的第三个参数表示用空格 或逗号,作为分隔符,所以由scan函数的定义显然。如果第三个参数只有逗号','则答案就是D了。
4.选A是因为set语句在length语句之前,调换这两个语句之后C就是对的了。因为SAS是sentence-by-sentence编程语言。
5.语句JobCategory= 'FA'; 决定了JobCategory变量的长度是2。JobCategory || JobLevel=‘FA1',但由于长度是2,所以后面1被截取掉了,结果保持不变!
proc print data = sasuser.houses;
where price gt 100000;
run;
所以不对.
2.SAS是在编译阶段就决定变量的长度的,所以length(first)=length(scan(author,1,' ,')).而在没有其他语句(对变量长度有影响的语句,如length语句等)的情况下,用scan函数赋值的变量默认长度为200(SAS中字符型变量的最长长度)。
3.程序中scan函数的第三个参数表示用空格 或逗号,作为分隔符,所以由scan函数的定义显然。如果第三个参数只有逗号','则答案就是D了。
4.选A是因为set语句在length语句之前,调换这两个语句之后C就是对的了。因为SAS是sentence-by-sentence编程语言。
5.语句JobCategory= 'FA'; 决定了JobCategory变量的长度是2。JobCategory || JobLevel=‘FA1',但由于长度是2,所以后面1被截取掉了,结果保持不变!
全部回答
- 1楼网友:人類模型
- 2021-02-15 17:39
因为条件level=2 or 3总是为真!语句else expertise = 'high'; 总不会被执行!
level=2 or 3=(level=2) or (3)=(true or false) or (true)=true!
- 2楼网友:你哪知我潦倒为你
- 2021-02-15 16:01
1. A答案是不对的,执行最下面那个where price gt 100000;
2. scan函数赋值的变量默认长度为200
3. 空格分割,取第3个。
4. length 须在set前才能变字符变量长度。数值变量都是8位(2进)
5.变量长度问题。读入栈是长度。JobCategory= 'FA'; 决定了JobCategory变量的长度是2
- 3楼网友:duile
- 2021-02-15 15:08
最后一问 今天看了。这题目贱,所以一定要细心。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯