SAS Base认证考试—70题(41-50)

2019-08-03 10:33

SAS Base认证考试—70题(41-50) Q 41

Given the raw data record in the file phone.txt: ----|----10---|----20---|----30---|

Stevens James SALES 304-923-3721 14 The following SAS program is submitted: data WORK.PHONES; infile 'phone.txt';

input EmpLName EmpFName <_insert_code_> run;

Which SAS statement completes the program and results in a value of \variable FullName?

A. FullName=CATX(' ',EmpFName,EmpLName); B. FullName=CAT(' ',EmpFName,EmpLName); C. FullName=EmpFName!!EmpLName; D. FullName=EmpFName + EmpLName; 答案:A

本题知识点:CAT系列函数

cat(of x1-x4):即x1||x2||x3||x4

catt(of x1-x4):即trim(x1)||trim(x2)||trim(x3)||trim(x4) cats(of

x1-x4)

Dept Phone

Extension;

trim(left(x1))||trim(left(x2))||trim(left(x3))||trim(left(x4)) catx(sp,of x1-x4):即

trim(left(x1))||sp||trim(left(x2))||sp||trim(left(x3))||sp||trim(left(x4)) 为什么没有选C。从理解上,应该正确。但是,实际上是不对的。这正是SAS编程与其他语言的差异之一。

查看变量长度,可以发现,没有LENGTH语句申明长度时,默认每个变量(无论数值型或字符型)读取的长度都是8,不足的以空格填充。 proc contents data=WORK.PHONES varnum; run;

选项C的结果为FullName=’James Stevens‘,中间是空格是3个空格,即 James_ _ _ Stevens_ Q 42

The following SAS program is submitted: data WORK.ONE;

Text='Australia, US, Denmark'; Pos=find(Text,'US','i',5); run;

What value will SAS assign to Pos? A. 0 B. 1 C. 2 D. 12 答案:D

本题知识点:字符串查找函数:FIND函数

FIND(string,substring<,modifiers><,startpos>) FIND(string,substring<,startpos><,modifiers>) 返回substring在原字符串string中的位置。

modifiers参数:’i'是忽略大小写;’t'是去掉string,substring的空格。 Q 43

Given the SAS data set WORK.ORDERS: WORK.ORDERS

order_id customer shipped -------- ------------ --------- 9341 Josh Martin 02FEB2009 9874 Rachel Lords 14MAR2009 10233 Takashi Sato 07JUL2009

The variable order_id is numeric; customer is character; and shipped is numeric, contains a SAS date value, and is shown with the DATE9. format.

A programmer would like to create a new variable, ship_note, that shows a character value with the order_id, shipped date, and customer name.

For example, given the first observation ship_note would have the value \02FEB2009 to Josh Martin\

Which of the following statement will correctly create the value and assign it to ship_note? A. ship_note=catx(' ','Order',order_id,'shipped on',input(shipped,date9.),'to',customer); B. ship_note=catx(' ','Order',order_id,'shipped on',char(shipped,date9.),'to',customer); C. ship_note=catx(' ','Order',order_id,'shipped on',transwrd(shipped,date9.),'to',customer); D. ship_note=catx(' ','Order',order_id,'shipped on',put(shipped,date9.),'to',customer); 答案:D

本题知识点:CAT系列函数、变量数据类型的显式转换 CAT系列函数,参考第41题。

如果字符型变量转换后不能作为标准数值读入,被转换成的字符型变量有格式要求,必须进行显式转换。

1)、字符型变量 -> 数值型变量 INPUT(source,informat)

其中,source是被转换的字符型变量,informat是读取数字型变量的输入格式。 2)、数值型变量 -> 字符型变量 PUT(source,format)

其中,source是被转换的数字型变量,format是一个输出格式。

Q 44

The following SAS program is submitted: data ONE TWO SASUSER.TWO set SASUSER.ONE; run;

Assuming that SASUSER.ONE exists, how many temporary and permanent SAS data sets are created?

A. 2 temporary and 1 permanent SAS data sets are created B. 3 temporary and 2 permanent SAS data sets are created C. 2 temporary and 2 permanent SAS data sets are created D. there is an error and no new data sets are created 答案:D

本题知识点:永久数据集、临时数据集

参考第26题。但此题DATA语句缺少分号,存在语法错误。 Q 45

The following SAS program is submitted: ods csvall file='c:\\test.cvs'; proc print data=WORK.ONE; var Name Score Grade; by IdNumber; run;

ods csvall close;

What is produced as output?

A. A file named test.cvs that can only be opened in Excel.

B. A text file named test.cvs that can be opened in Excel or in any text editor. C. A text file named test.cvs that can only be opened in a text editor.

D. A file named test.cvs that can only be opened by SAS. 答案:C

本题知识点:CSV的打开问题

CSV是一种用来存储数据的纯文本文件,通常都是用于存放电子表格或数据的一种文件格式。

CSV 文件格式只能保存活动工作表中的单元格所显示的文本和数值。数据列以逗号分隔,每一行数据都以回车符结束。

? ? ? ?

如果单元格中包含逗号,则该单元格中的内容以双引号引起。 如果单元格显示的是公式而不是数值,该公式将转换为文本方式。 所有格式、图形、对象和工作表的其他内容将全部丢失。 欧元符号将转换为问号。

用记事本和excel、Editplus等文本编辑器都能打开。记事本打开显示逗号;excel打开,没有逗号。

本题也是很多人讨论答案,其实是没有仔细读题。

注意题目中说得是后缀为*.CVS的文件,这个是SAS自定义的文本文件格式,答案也选B。 如果是后缀为*.CSV的文件,答案就是B。 Q 46

Given the SAS data set WORK.ONE:

Obs Revenue2008 Revenue2009 Revenue2010 --- ----------- ----------- ----------- 1 1.2 1.6 2.0 The following SAS program is submitted: data WORK.TWO; set WORK.ONE; Total=mean(of Rev:); run;


SAS Base认证考试—70题(41-50).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:C语言笔试

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: