-
SAS Base
认证考试
—
< br>70
题
SAS
分多个认证种类:
base
,
advanced
,
clinic
等,
但大多需要先通过
base
认证。
<
/p>
但凡这类商业组织提供的考证,基本都是题库型,所以想考过难度并不大。
对于只想拿
SAS
认证的人
,如果熟练掌握网上流传甚广的
sas
真题
70
题,通过
base
认证基本就
没问题。
Q 1
1. The
following SAS program is submitted:
data
set
by
Department Gender;
if
First.<_insert_code_> then Payroll=0;
Payroll+Wagerate;
if
Last.<_insert_code_>;
run;
The SAS data set is currently ordered
by Gender within Department.
Which
inserted code will accumulate subtotals for each
Gender within Department?
A. Gender
B. Department
C. Gender
Department
D. Department Gender
答案:
A
本题知识点:自动变量
在
SAS
读取数据时,在
PDV
过程中会产生很多自动变量,在输出的数据集中是不可见的。
·
LE
:同一个
BY
变量(组),若新的变量值第一次出现时,其
le
p>
值为
1
。
·
LE
:同一个
BY
变量(组),若新的变量值最后一次出现时,其
le<
/p>
值为
1
。
p>
另外,在
BY
变量右面有多个变量时,先按
第一个变量排序,若第一个变量的观测存在重复时,才按第二个
变量排序。
Q 2
Given the following raw data records in
:
1
----|----10---|----20---|----30
John,FEB,13,25,14,27,Final
John,MAR,26,17,29,11,23,Current
Tina,FEB,15,18,12,13,Final
Tina,MAR,29,14,19,27,20,Current
The
following output is desired:
Obs Name
Month Status Week1 Week2 Week3 Week4
Week5
1 John FEB Final
$$13 $$25 $$14 $$27 .
2 John MAR Current $$26 $$17 $$29
$$11 $$23
3 Tina FEB Final
$$15 $$18 $$12 $$13 .
4 Tina MAR Current $$29 $$14 $$19
$$27 $$20
Which SAS program correctly
produces the desired output?
A. data S;
length Name $$ 4 Month $$ 3 Status $$ 7;
infile '' dsd;
input Name $$
Month $$;
if Month='FEB' then input
Week1 Week2 Week3 Week4 Status $$;
else
if Month='MAR' then input Week1 Week2 Week3 Week4
Week5 Status $$;
format Week1-Week5
dollar6.;
run;
proc print
data=S;
run;
B. data S;
length Name $$ 4 Month $$ 3 Status $$ 7;
infile '' dlm=',' missover;
input Name $$ Month $$;
if
Month='FEB' then input Week1 Week2 Week3 Week4
Status $$;
else if Month='MAR' then
input Week1 Week2 Week3 Week4 Week5 Status $$;
format Week1-Week5 dollar6.;
2
run;
proc print data=S;
run;
C. data S;
length Name $$ 4
Month $$ 3 Status $$ 7;
infile ''
dlm=',';
input Name $$ Month $$ @;
if Month='FEB' then input Week1 Week2
Week3 Week4 Status $$;
else if
Month='MAR' then input Week1 Week2 Week3 Week4
Week5 Status $$;
format Week1-Week5
dollar6.;
run;
proc print
data=S;
run;
D. data S;
length Name $$ 4 Month $$ 3 Status $$ 7;
infile '' dsd @;
input Name
$$ Month $$;
if Month='FEB' then input
Week1 Week2 Week3 Week4 Status $$;
else
if Month='MAR' then input Week1 Week2 Week3 Week4
Week5 Status $$;
format Week1-Week5
dollar6.;
run;
proc print
data=S;
run;
答案:
C
本题知识点:
INFILE
语句与指示
器
@
、
@@
INFILE filespecification options;
其中,
filespecification
用来
定义文件
,
options
给出选择项
;
·
filespecification
有以下三种形式
:
3
①
、<
/p>
fileref(
文件标志
)
②
、
’filename’(
< br>文件名
)
③
、
CARDS
指明输入的数据,紧跟着
CARDS
语句
·
下列选择项
(options)
可以出现在<
/p>
INFILE
语句中
:
①
、
COLUMN=variable
或
COL=variable
定义一个变量
,
其值是指针所在的当前列位置。
②
、
END=variable
定义一个变量
,
作为文件结束的标志。
③
、
EOF=label
是一个语句标号
,
当
INFILE
语句
读到文件末尾时
,
作为隐含的
GOT
O
语句的目标。
④
、
LENGHT=variable
定义一个变量
,
其值是当前输入数据行的长度。
⑤<
/p>
、
FIRSTOBS=linenumber
要求从指定的行开始读取数据
,
而不是从文件的第一个记录开始。
⑥
、
OBS=n
指定从一个顺序输入文件中读取数据的最后一个行
(
即第<
/p>
1
~第
n
行
p>
)
。一个观察可能占
n
行。
⑦
、
DLM=
若分隔符不是空格,则使用
DLM=
指定
⑧
、
DSD
忽略引号中数值的分隔符;自动将字符数据中的引号去掉;将两个相邻分隔符视为缺失值处理。<
/p>
⑨
、
MISSOVER
阻止
INPUT
进入下一行读取,未赋值变量视为缺
失值。
⑩
、
TRUNCOVER
与
MISSOVER
相似,但在
< br>COLUMN INPUT
或
FORMATTED
INPUT
中使用。
比较
@
与
@@
的区别:
·
@
用于
1
个数据行用多个
input
语句读取,停留到下一个
INPUT<
/p>
语句。
·
@@
用于
1
个数据行含有多个观测值
读取时,停留到下一个
DATA
步。
Q 3
The following SAS program is submitted:
data _INFO;
Day=
Yr=1960
X=mdy(Day,01,Yr)
run;
What
is the value of the variable X?
A. the
numeric value 0
B. the character value
C. a missing value due to syntax errors
D. the step will not compile because of
the character argument in the mdy function.
4
答案:
A
本题知识点:数据类型的自动转换
在
SAS
中,日期时间是以
1960
p>
年
1
月
1
日
0
时
0
分
0
秒作为起点的。因此,
mdy(1,1,1960)=0
。
若把日期时间表示为常数时,要使用相应的格式,带单或双引号,在后面紧跟一个
D
p>
(日期)、
T
(时间)、
< br>DT
(日期时间)。
在本题中
,日期函数的参数应该是数值,若是字符串,会先尝试字符串是否可以转换为数值,这是自动转
< br>换。
自动转换是指系统产生一个临时的变量来完成赋值
或运算。当自动转换发生时,会在
LOG
窗口中给出提示。
p>
1
)、字符型变量
->
数值型变量
在下面的情况中,<
/p>
VarB
是一个字符型变量,其它是数字型变量。
·
赋值于一个数字型变量,如:
VarA=VarB;
·
在算术运算中使用,如:
VarA=VarB+0;
·
与一个数字型变量进行比较,如:
if
VarB>=VarA;
·
在函数
中,参数要求数字型变量,如:
VarA=sum(VarB,0);
2
)、数值型变量
->
字符型变量
在下面的情况中,<
/p>
VarB
是一个数字型变量,其它是字符型变量。
·
赋值于一个字符型变量,如:
VarA=VarB;
·
在与要求字符的运算符一起使用,
如:
VarA=''||VarB;
·
在函数中,参数要求字符型变量,
如:
VarA=trim(VarB);
Q 4
The Excel workbook
contains the following four worksheets:
EAST
WEST
NORTH
SOUTH
The following program is submitted:
libname MYXLS '';
5
Which PROC PRINT step
correctly displays the NORTH worksheet?
A. proc print data=;run;
B.
proc print data=$$;run;
C. proc print
data=MYXLS.'NORTH'e;run;
D. proc print
data=MYXLS.'NORTH$$'n;run;
答案:
D
本题知识点:打印
Excel
的某个工作表的数据
WHAT IS THAT “$$” CH
ARACTER?
Looking at SAS Explorer it may be
surprising that each dataset written to Excel
appears twice, once with the
expected
name and once with a trailing “$$”.
Unlike a typical data source,
data in an Excel spreadsheet need not be left and
top aligned. For this Excel has
named
ranges which allow data to be placed anywhere
inside a spreadsheet. By default SAS reads and
writes data
from named ranges on
spreadsheets, but will also read spreadsheet data
directly in the absence of a named range.
When a new SAS dataset is created
in an Excel library, SAS creates both a
spreadsheet and a named range. Each
is
given the same name, with thespreadsheet denoted
by a trailing “$$”.
In
the example at right CLASS is the named range
created by the Excel engine and CLASS$$ is the
spreadsheet
created by the Excel engine
to hold the named range. Within SAS, the named
range is referred to as ,
and the
spreadsheet is referenced using the name literal
Wrkbk.’CLASS$$’n.
SAS
name literals are name tokens written as strings
within quotation marks, followed by the letter n.
Name
literals allow the use of special
characters that are not otherwise allowed in SAS
names , like the “$$” used by the
Excel
libname engine to distinguish worksheets from
named ranges. For more information see the
Recommended
Readings.
摘自《
De-Mystifying the SAS
LIBNAME Engine in Microsoft Excel: A Practical
Guide
》
Q 5
Which statement
specifies that records 1 through 10 are to be read
from the raw data file ?
A. infile ''
1-10;
B. input '' stop@10;
C. infile '' obs=10;
D.
input '' stop=10;
答案:
C
本题知识点:
INFILE
的选项
FIRSTOBS=
常数,要求从指定的行开始读
取数据
,
而不是从文件的第一个记录开始。
O
BS=
常数,指定从一个顺序输入文件中读取数据的最后一个行
(
即第
1
~第
n
行
)
。一个观测可能占
n
行。
6
Q 6
After a SAS program is submitted, the
following is written to the SAS log:
101 data Y;
102 set
R(keep=product month num_Sold Cost);
103 if Month='Jan' then output Y;
104 Sales=Cost * Num_Sold;
105
keep=Product Sales;
-----
22
ERROR 22-322: Syntax error, expecting
one of the following: !,
!!, &, *, **, +, -,
, <=, <>, =, >,
>=,
AND, EQ, GE, GT,
IN, LE, LT, MAX, MIN, NE, NG, NL,
NOTIN, OR, ^=, |, ||, ~=.
106 run;
What changes should be made to the KEEP
statement to correct the errors in the LOG?
A. keep=(Product Sales);
B.
keep Product, Sales;
C. keep=Product,
Sales;
D. keep Product Sales;
答案:
D
本题知识点:
KEEP
语句与
KEEP=
选项
在处理大型数据集时,
KEEP
=
选项的效率较高。
·
KEEP
语句:
KEEP variable(s);
不能用于过程步。
·
KEEP=
选项:
data-set-name(
KEEP=variable(s) )
可以用于数据步(如,
DATA
语句、
SET
语句)、过
程步。
其中,
variable(s)
是具体变量,不能是数组、
_N_
、
_
ERROR_
等。
Q 7
7
Which of the following
choices is an unacceptable ODS destination for
producing output that can be viewed in
Microsoft Excel?
A.
MSOFFICE2K
B. EXCELXP
C.
CSVALL
D. WINXP
答案:
D
本题知识点:
ODS
输出
Most
of these destinations are designed to create
output for viewing on a screen or for printing.
The OUTPUT destination creates SAS data
sets. The MARKUP destination is a general purpose
tool for creating output in formats
defined by tagsets. This includes XML (eXtensible
Markup
Language), EXCELXP, LaTeX, CSV
(comma-separated values), and many other formats
where data
can be thought of as
separated by tags. The DO CUMENT destination, on
the other hand, allows
you to create a
reusable output “document” that yo u can rerender
for any destination. So, if your
boss decides he really wants that
report in PDF, not RTF, you can replay the output
document
without having to rerun the
entire SAS program that created the data. With an
output document,
you can also
rearrange, duplicate, or delete tables to further
customize your output.
摘自《
The Little SAS
Book
》
(Fourth)
P152
页
Q 8
The SAS data set named
contains 10 observations for each department, and
is currently ordered by
Department.
The following SAS program is submitted:
data
set (keep=Department
MonthlyWageRate);
by Department;
if ment=1 then Payroll=0;
Payroll+(MonthlyWageRate*12);
if
ment=1;
run;
Which statement
is true?
A. The by statement in the
DATA step causes a syntax error.
B. The
statement Payroll+(MonthlyWageRate*12); in the
data step causes a syntax error.
8
C. The values of the
variable Payroll represent the monthly total for
each department in the data
set.
D. The values of the variable Payroll
represent a monthly total for all values of
WAGERATE in the
data set.
答案:
C
本题知识点:类似第
1
题
Q 9
data course;
input exam;
datalines;
50.1
;
run;
proc format;
value score 1
–
50 =
‘Fail’
51
–
100 =
‘Pass’;
run;
proc
report data =course nowd;
column exam;
define exam / display format=score.;
run;
What is the value for
exam?
A. Fail
B. Pass
C. 50.1
D. No output
答案:
C
本题知识点:
PROC
FORMAT
语句
PROC
FORMAT;
VALUE name
range-
1=’formatted
-text-
1′
;
range-
2=’format
ted
-text-
2′;
……
range-
< br>n=’formatted
-text-
n’;
9
若
name
为字符串设计格式,则必须在开头加
$$<
/p>
,长度不超过
32
字节;
name
不能以数字结尾,除了下划线外,不能含其
他的任何特殊字符。
在
range<
/p>
右侧文本可达到
32767
字节。
·
变量值是字符串要加引号。
·
range
是多个值,要用逗号。
·
连续的要用
-
。
·
关键字
low
、
high
指代变量中最小和最大的非缺失值。
·
用
<
p>
排除或指代某些范围。
·
other
是给其他没列在
VALUE
中的变量分配格式。
Q 10
The
following SAS program is submitted:
data
Cost='$$20.000';
Discount=.10*Cost;
run;
What is the result?
A. The
value of the variable Discount in the output data
set is 2000. No messages are written to the SAS
log.
B. The value of the variable
Discount in the output data set is 2000. A note
that conversion has taken place is
written to the SAS log.
C.
The value of the variable Discount in the output
data set is missing. A note in the SAS log refers
to invalid
numeric data.
D.
The variable Discount in the output data set is
set to zero. No messages are written to the SAS
log.
答案:
C
本题知识点:标准数据、以及数据类型的自动转换
非标准数据
·
含逗号的数值,如:
1,00,001
;
·
包含美元符号、十六进制、压缩十进制的数据;
·
日期是最普通的非标准数据。
标准数据
10
·
数字
0-9
·
英文句号
·
科学计数、
E
·
+
、
-
如果字符型变量转换后不能作为标准数值读入,被转换成的字符型变量有格式要求,必须
进行显式转换。
Q
11
Given the existing SAS
program:
proc
format;
value
agegrp
low-12
='Pre-Teen'
13-high = 'Teen';
run;
proc means
data=;
var
Height;
class Sex
Age;
format Age
agegrp.;
run;
Which statement in the
proc means step needs to be modified or
added
to generate the
following results:
Analysis Variable :
Height
N
Sex Age Obs
Minimum Maximum Mean
------------------------------------
------------------------------
F Pre-Teen 3 51.3
59.8 55.8
Teen 6 56.5 66.5
63.0
M Pre-Teen 4
57.3 64.8 59.7
Teen 6 62.5
72.0 66.8
----
--------------------------------------------------
--------------
A. var Height
/ nobs min max mean maxdec=1;
B. proc means data= maxdec=1
;
C. proc means data= min
max mean maxdec=1;
D. output
nobs min max mean maxdec=1;
答案:
C
本题知识点:
PROC
MEANS
过程
PROC
MEANS
语句
;
RUN;
?
data=
:数据集
maxdec=
:指定输出结果的小数位数,默认为
7
位
noprint
< br>:禁止结果在
OTPUT
窗口输出
alpha
:设定可信区间的
α<
/p>
水平,默认为
0.05
?
MAX
、
MIN
、
MEAN
、
MEDIAN
、
N
、
NMISS
、
RANGE
、
STDDEV
、
S
UM
11
若不加统计关键词,默认打印的顺序:
非缺失值个数(
N
)、均值(
MEA
N
)、标准差(
STDDEV
)、最小
值(
MIN
)、最大值(
MAX
)。
?
语句
若在
PROC MEAN
过程中没有其
他语句,默认输出所有观测值和所有数值变量的统计量。
BY
:分变量单独分析,数据必须先按变量顺序排序,即
PROC
SORT
CLASS
:分变量单独分
析,不用排序
VAR
:指定使用的数值变量
Q 12
The Excel workbook contains
the
following three
worksheets:
JAN
FEB
MAR
Which
statement correctly assigns a library reference to
the Excel workbook?
A.
libname qtrdata '';
B.
libname '' sheets=3;
C.
libname jan feb mar '';
D.
libname mydata '' =(jan,feb,mar);
答案:
A
本题知识点:
LIBNAME
语句格式
LIBNAME libref
‘SAS
-data-
library’
< options >
Q 13
The
following SAS program is submitted:
data
set
S(keep=Janpt Febpt Marpt);
array Diff{3} Difcount1-Difcount3;
array Patients{3} Janpt Febpt
Marpt;
run;
What new variables are
created?
A. Difcount1,
Difcount2 and Difcount3
B.
Diff1, Diff2 and Diff3
C.
Janpt, Febpt, and Marpt
D.
Patients1, Patients2 and Patients3
答案:
A
本题知识点:数组
与其他编程语言的
数组相比不同在于,
SAS
数组的每个元素都对应一个变量名。
?
数值型数组
数组说明中的初始值可省略,默认为缺失值。
数组说明中变量可省略,变量名默认为数组名
+
序号。
序号从
1
开始。
ARRAY test(3)
Math Chinese
English (0,0,0)
;
数组元素的个数由变量个数决定。
ARRAY test(*) test3-test8;
<
/p>
二维数组,数组元素按
行
排列。
ARRAR x(2,2) x11 x12 x21
x22;
?
字符型数组
12
字符型数组药指定数组元素的最大长度,其他与数值型数组相
同。
ARRAY test(2) $$ 10 mathor
father;
?
临时数组
若
SAS
数组每个元素不对应变量名,即为临时数组。这与其他编程语言相同。
ARRAY test(3) _TEMPORARY_
(0,0,0);
临时数组只用于中间计算,不保存入数据集。
在数据步中,临时数组在数据步隐含循环中能自动保留上一步得到的值。
Q 14
Which of the following programs
correctly invokes the DATA Step
Debugger:
A. data
debug;
set
State=scan(cityState,2,'
');
if State='NE' then
description='Central';
run;
B. data
debugger;
set
;
State=scan(cityState,2,' ');
if State='NE' then
description='Central';
run;
C. data /
debug;
set
;
State=scan(cityState,2,' ');
if State='NE' then
description='Central';
run;
D. data /
debugger;
set
;
State=scan(cityState,2,' ');
if State='NE' then
description='Central';
run;
答案:
C
本题知识点:
/ debug
语法
DEBUG
过程的调用方法:在
DATA
步后面增加
< br>DEBUG
选项。
Q 15
Which statement is true concerning the
SAS automatic variable _ERROR_?
A. It cannot be used in an if/then
condition.
B. It cannot be
used in an assignment statement.
C. It can be put into a keep statement
or keep= option.
D. It is
automatically dropped.
答案:
D
本题知识点:自动变量
_ERROR_
在
PDV
过程中,产生很多自动变量,
可以在数据步的表达式中使用,在输出数据集中不可见。
在
PD
V
过程中,
_N_
、
< br>_ERROR_
默认为
DROP
。
在
KEEP
语句或
KEEP=
选项中,可以使用除了
_N_
、
_ERROR_
之外的变
量。
Q
16
The following SAS program
is submitted:
data
_INFO;
X='04jul2005'd;
13
DayOfMonth=day(x);
MonthOfYear=month(x);
Year=year(x);
run;
What types
of variables are DayOfMonth, MonthOfYear, and
Year?
A. DayOfMonth, Year,
and MonthOfYear are character.
B. DayOfMonth, Year, and MonthOfYear
are numeric.
C. DayOfMonth
and Year are numeric. MonthOfYear is
character.
D. DayOfMonth,
Year, and MonthOfYear are date values.
答案:
B
本题知识点:
SAS
中日期时间及函数
起点:
1960
年
1
月
1
日
0
时
0
分<
/p>
0
秒。
若将日期时间标示为数值型常数,需使用相应格式。
格式值带单引号,后跟一个
D
(日期)、
T
(时间)、
DT
(
日期时间)。
日期函数返回值为数值。
Q 17
Given the following data
step:
data
infile datalines;
input City $$20.;
if City='Tulsa' then
State='OK';
Region='Central';
if
City='Los Angeles' then
State='CA';
Region='Western';
datalines;
Tulsa
Los
Angeles
Bangor
;
run;
After data step execution, what will
data set contain?
A.
City State
Region
-----------
----- -------
Tulsa
OK Western
Los
Angeles CA Western
Bangor Western
B.
City State
Region
-----------
----- -------
Tulsa
OK Western
Los
Angeles CA Western
Bangor
C.
City
State Region
----------- ----- -------
Tulsa OK
Central
Los Angeles
CA Western
Bangor
Western
D.
City
State Region
----------- ----- -------
Tulsa OK
Central
Los
CA Western
Bangor
14
答案:
A
本题知识点:
IF
语句
若执行语句不能在一个语句完成,则使用复合语
句
DO
和
END
IF
条件
THEN
语句
;
没有
ENDIF
,没有
IF-
ELSEIF-ELSE
多分支结构
,
语句
1
只能是一个语句。
IF
条件
THEN
语句
1;
语句前后均无差别。 打印 个。
选项
语句
2>
;
Q 18
Which statement describes a
characteristic of the SAS automatic variable
_ERROR_?
A. The _ERROR_
variable maintains a count of the number of data
errors in a DATA step.
B.
The _ERROR_ variable is added to the program data
vector and becomes part of the data set being
created.
C. The _ERROR_ variable can be
used in expressions in the DATA step.
D. The _ERROR_ variable contains the
number of the observation that caused the data
error.
答案:
C
本题知识点:
WHERE
语句
类似第
15
题。
p>
Q
19
The SAS data set
contains a numeric variable named Num and a
character variable named Char:
Num Char
--- ----
1 23
3 23
1 77
The
following SAS program is submitted:
proc print data=;
where Num='1';
run;
What is
output?
A.
Num
Char
---
----
1
23
B.
Num Char
--- ----
1 23
1 77
C.
Num
Char
---
----
1
23
3 23
1 77
D.
No output is generated.
答案:
D
本题知识点:
WHERE
语句
WHERE
语句无法找到满足条件的观测。<
/p>
Q
20
15
The data set
TATE has the variable LocalFee with a format of 9.
and a variable CountryFee with a
format
of 7.;
The following SAS program is
submitted:
data
_STRUCTURE;
format
LocalFee CountryFee percent7.2;
set TAT;
LocalFee=LocalFee/100;
CountryFee=CountryFee/100;
run;
What are the
formats of the variables LOCALFEE and COUNTRYFEE
in the output dataset?
A.
LocalFee has format of 9. and CountryFee has a
format of 7.
B. LocalFee has
format of 9. and CountryFee has a format of
percent7.2
C. Both LocalFee
and CountryFee have a format of
percent7.2
D. The data step
fails execution; there is no format for
LocalFee.
答案:
C
本题知识点:
FORMAT
语句
FORMAT
语句为非执行语句。
FORMAT
语句在
SET
FORMAT
可以使用在数据步和过程步中,前者把格式永久存储,后者只是临时存储(当前过程中有作用)。
Q 21
Given
the SAS data set TS:
ProdId Price ProductType Sales
Returns
------ -----
----------- ----- -------
K12S 95.50 OUTDOOR
15 2
B132S
2.99 CLOTHING 300 10
R18KY2 51.99 EQUIPMENT
25 5
3KL8BY
6.39 OUTDOOR 125 15
DY65DW 5.60 OUTDOOR
45 5
DGTY23
34.55 EQUIPMENT 67
2
The following SAS program
is submitted:
data R
;
set TS;
if Sales GT 30;
if ProductType EQ 'OUTDOOR' then
output R;
else if
ProductType EQ 'CLOTHING' then output
else if ProductType EQ 'EQUIPMENT'
then output
run;
How many
observations does the R data set
contain?
A. 1
B. 2
C.
3
D. 6
答案:
B
本题知识点:
IF
子集、
OUPUT
语句
子集
p>
IF
语句对满足条件的观测输出到正在被创建的数据集中。
Q
22
Which step displays a
listing of all the data sets in the WORK
library?
A. proc contents
lib=WORK run;
B. proc
contents lib=;run;
C. proc
contents data=WORK._all_; run;
D. proc contents data=WORK _ALL_;
run;
16
答案:
C
本题知识点:
PROC
CONTENTS
过程
默认自动打印最近创建的数据集的描述信息
PROC CONTENTS;RUN;
打印当前目录下的全部数据集的描述信息
PROC CONTENTS DATA=_ALL_;RUN;
WORK
临时逻辑库下数据集的描述信息
PROC CONTENTS
DATA=WORK._ALL_;RUN;
Q 23
Which is a
valid LIBNAME statement?
A.
libname
B. sasdata libname
C. libname sasdata
D. libname sasdata sas
答案:
C
本题知识点:
LIBNAME
p>
定义逻辑库
参考第
12
题。
Q 24
Given the following raw data
records:
----|----10---|----20---|----30
Susan*12/29/1970*10
Michael**6
The
following output is desired:
Obs employee bdate
years
1 Susan
4015 10
2 Michael
. 6
Which SAS program
correctly reads in the raw data?
A. data employees;
infile 'file specification'
dlm='*';
input
employee $$ bdate : mmddyy10. years;
run;
B. data
employees;
infile
'file specification' dsd='*';
input employee $$ bdate
mmddyy10. years;
run;
C. data
employees;
infile
'file specification' dlm dsd;
input employee $$ bdate
mmddyy10. years;
run;
D. data
employees;
infile 'file specification' dlm='*'
dsd;
input
employee $$ bdate : mmddyy10. years;
run;
答案:
D
本题知识点:
INFILE
语句
参考第
2
题。
17
Q 25
Given the
following code:
proc print
data=(firstobs=5 obs=15);
where Sex='M';
run;
How many observations
will be displayed?
A.
11
B. 15
C. 10 or fewer
D.
11 or fewer
答案:
D
本题知识点:
WHERE
子集
计算
15-5+1=11
WHERE
子集的观测最多
为
11
个。
Q 26
Which step sorts the observations of a
permanent SAS data set by two variables and stores
the sorted observations in
a temporary
SAS data set?
A. proc sort
out=EMPLOYEES data=EMPSORT;
by Lname and Fname;
run;
B. proc sort data=EES
out=EMPSORT;
by
Lname Fname;
run;
C. proc sort out=EES
data=T;
by Lname
Fname;
run;
D. proc sort data=EES out=T;
by Lname and
Fname;
run;
答案:
B
本题知识点:永久数据集、临时数据集
逻辑库
.
成员
逻辑库
数据集
DATA weight;
work
(默认)
临时的
DATA
work
临时的
DATA Bikes
永久的
Q 27
Given the
SAS data set :
Day Month
Temp
--- -----
----
1 May
75
15 May
70
15 June
80
3 June
76
2 July
85
14 July
89
The following program is
submitted:
proc sort
data=;
by
descending Month Day;
run;
18
proc print data=;
run;
Which
output is correct?
A.
Obs Day
Month Temp
--- ---
----- ----
1 2
July 85
2 14
July 89
3 3
June 76
4 15
June 80
5 1
May 75
6 15
May 7
B.
Obs Day Month Temp
--- --- ----- ----
1 1 May 75
2 2 July 85
3 3 June 76
4 14 July 89
5 15 May 70
6 15 June 80
C.
Obs Day
Month Temp
--- ---
----- ----
1 1
May 75
2 15
May 70
3 3
June 76
4 15
June 80
5 2
July 85
6 14
July 89
D.
Obs Day Month Temp
--- --- ----- ----
1 15 May 70
2 1 May 75
3 15 June 80
4 3 June 76
5 14 July 89
6 2 July 85
答案:
C
本题知识点:
BY
语句
BY
<…
variable-
n>
当使用
BY
语句时,
first.
变量与
las
t.
变量才有效。
BY
语句中变量默认是升序排列的。
DESCENDING
(降序)只作用于它后面的第一个变量。
BY
语句的排序是按字符的先后顺序
排序的。
Q 28
Given the
SAS data set WORK.P2000:
Location Pop2000
-------- -------
Alaska
626931
19
Delaware 783595
Vermont 608826
Wyoming 493782
and the SAS data set
WORK.P2008:
State
Pop2008
--------
-------
Alaska
686293
Delaware
873092
Wyoming
532668
The following output
is desired:
Obs State
Pop2000 Pop2008 Difference
1 Alaska 626931 686293
59362
2 Delaware
783595 873092 89497
3 Wyoming 493782 532668
38886
Which SAS program
correctly combines the data?
A. data compare;
merge WORK.P2000(in=_a Location=State)
WORK.P2008(in=_b);
by State;
if _a and _b;
Difference=Pop2008-Pop2000;
run;
B. data
compare;
merge
WORK.P2000(rename=(Location=State))
WORK.P2008;
by State;
if _a and _b;
Difference=Pop2008-Pop2000;
run;
C. data
compare;
merge
WORK.P2000(in=_a
rename=(Location=State))
WORK.P2008(in=_b);
by
State;
if _a and
_b;
Difference=Pop2008-Pop2000;
run;
D. data
compare;
merge
WORK.P2000(in=_a)
(rename=(Location=State))
WORK.P2008(in=_b);
by
State;
if _a and
_b;
Difference=Pop2008-Pop2000;
run;
答案:
C
本题知识点:
MERGE
语句
IN
选项、
RENAME=
MERGE
语句可以实现多
表横向合并。
MERGE sas-data-set-1
<(data-
set-
options)><…sas
-data-
set-n <(data-set-
options)>
IN=
选项:创建一个标示
变量,若当前观测属于某个数据集,标示为
1
,否则为
0
。
RENAME=
(表达式)选项:在
PDV
中,对指定
的变量更换变量名。
Q 29
The
following SAS program is sumbitted:
data
20
-
-
-
-
-
-
-
-
-
上一篇:房地产公司管理手册范本.docx
下一篇:天气和极端气候的观测和预测变化