好文档 - 专业文书写作范文服务资料分享网站

SAS base 50题 训练题(含答案及解析) 

天下 分享 时间: 加入收藏 我要投稿 点赞

28.The following SAS program is submitted:

ods html file='newfile.html'; proc print data=sasuser.houses; run;

proc means data=sasuser.houses; run;

proc freq data=sasuser.shoes; run;

ods html close;

proc print data=sasuser.shoes; run;

How many HTML files are created? a. 1 b. 2 c. 3 d. 4

Correct answer: a

By default, one HTML file is created for each FILE= option or BODY= option in the ODS HTML statement. The ODS HTML CLOSE statement closes the open HTML file and ends the output capture. The Newfile.html file contains the output from the PRINT, MEANS, and FREQ procedures.

You can learn about the ODS HTML statement in Producing HTML Output. 29.A frequency report of the variable Jobcode in the Work.Actors data set is listed below.

Jobcode Frequency Percent Cumulative Frequency Cumulative Percent

33.33 2 33.33 Actor I 2

33.33 4 66.67 Actor II 2

Actor III 2 33.33 6 100.00

Frequency Missing = 1

The following SAS program is submitted:

data work.joblevels; set work.actors;

if jobcode in ('Actor I', 'Actor II') then joblevel='Beginner';

if jobcode='Actor III' then joblevel='Advanced'; else joblevel='Unknown'; run;

Which of the following represents the possible values for the variable joblevel in the Work.Joblevels data set?

a. Advanced and Unknown only

SAS中文论坛网站http://www.mysas.net SAS中文论坛FTP站ftp://mysas.vicp.net

b. Beginner and Advanced only

c. Beginner, Advanced, and Unknown d. ' ' (missing character value) Correct answer: a

The DATA step will continue to process those observations that satisfy the condition in the first IF statement Although Joblevel might be set to Beginner for one or more observations, the condition on the second IF statement will evaluate as false, and the ELSE statement will execute and overwrite the value of Joblevel as Unknown. You can learn about

? ?

the IF statement in Creating SAS Data Sets from Raw Data the ELSE statement in Creating and Managing Variables.

30.The descriptor and data portions of the Work.Salaries data set are shown below.

Variable Type Len Pos name Char 8 0 salary Char 8 16 status Char 8 8

name status Liz S Herman S Marty S

salary 15,600 26,700 35,000

The following SAS program is submitted:

proc print data=work.salaries; where salary<20000; run;

What is displayed in the SAS log after the program is executed? a. A NOTE indicating that 1 observation is read. b. A NOTE indicating that 0 observations were read.

c. A WARNING indicating that character values have been converted to numeric values. d. An ERROR indicating that the WHERE clause operator requires compatible variables. Correct answer: d

Salary is defined as a character variable. Therefore, the value in the WHERE statement

must be the character value 20,000 enclosed in quotation marks. You can learn about the WHERE statement in Creating List Reports.

31.Which of the following statements is true when SAS encounters a syntax error in a DATA step?

SAS中文论坛网站http://www.mysas.net SAS中文论坛FTP站ftp://mysas.vicp.net

a. The SAS log contains an explanation of the error.

b. The DATA step continues to execute and the resulting data set is complete.

c. The DATA step stops executing at the point of the error and the resulting data set contains observations up to that point.

d. A note appears in the SAS log indicating that the incorrect statement was saved to a SAS data set for further examination. Correct answer: a

SAS scans the DATA step for syntax errors during the compilation phase. If there are syntax errors, those errors get written to the log. Most syntax errors prevent further processing of the DATA step.

You can learn about how SAS handles syntax errors in the DATA step in Understanding DATA Step Processing.

32.Which TITLE statement would display JANE'S DOG as the text of the title? a. title \b. title 'JANE\c. title \

d. title 'JANE' ' 'S DOG'; Correct answer: c

The title in a TITLE statement must be enclosed in a pair of matched quotation marks. Unbalanced quotation marks can cause problems for SAS. To hide an unmatched single quotation mark, surround the title text with matched double quotation marks. You can learn about

? ?

the TITLE statement in Creating List Reports

unbalanced quotation marks in Editing and Debugging SAS Programs.

33.The following SAS program is submitted:

data test;

input animal1 $ animal2 $ mlgrams1 mlgrams2; cards;

hummingbird ostrich 54000.39 90800000.87 ; run;

Which one of the following represents the values of each variable in the output data set?

animal1 animal2 mlgrams1 mlgrams2 a.

hummingb ostrich 54000.39 90800000 b. animal1 animal2 mlgrams1 mlgrams2 hummingb ostrich 54000.39 90800000.87

animal1 animal2 mlgrams1 mlgrams2 c.

hummingbird ostrich 54000.39 90800000 d. animal1 animal2 mlgrams1 mlgrams2

SAS中文论坛网站http://www.mysas.net

SAS中文论坛FTP站ftp://mysas.vicp.net

hummingbird ostrich 54000.39 90800000.87

Correct answer: b

The CARDS statement is an alias for the DATALINES statement. In the INPUT

statement, you must specify a dollar sign ($) after the variable name in order to define a character variable. If you do not specify otherwise, the default storage length for a variable is 8. In the example above, the character value hummingbird is truncated to hummingb. You can learn about

? ? ?

the DATALINES statement in Creating SAS Data Sets from Raw Data the INPUT statement in Reading Free-Format Data the default storage length for variables in Basic Concepts.

34.The SAS data sets Work.Employee and Work.Salary are shown below.

fname age Bruce 30 Dan 40 fname salary Bruce 25000 Bruce 35000 Dan 25000

Work.Employee

Work.Salary

The following merged SAS data set is generated:

Work.Empdata fname age totsal Bruce 30 60000 Dan 40 25000

Which one of the following SAS programs created the merged data set? a. data work.empdata;

merge work.employee work.salary; by fname;

if first.fname then totsal=0; totsal+salary;

if last.fname then output; run;

data work.empdata(drop=salary); b.

merge work.employee work.salary; by fname;

SAS中文论坛网站http://www.mysas.net SAS中文论坛FTP站ftp://mysas.vicp.net

if first.fname then totsal=0; totsal+salary;

if last.fname then output; run;

data work.empdata; c.

merge work.employee

work.salary(drop=salary); by fname;

if first.fname then total=0; totsal+salary;

if last.fname then output; run;

data work.empdata; d.

merge work.employee work.salary; by fname;

if first.fname then total+salary; run;

Correct answer: b

The MERGE and BY statements allow you to match-merge two or more SAS data sets. The BY statement creates two temporary variables, First.Fname and Last.Fname for BY group processing. The SUM statement is used to add salary for each BY group. The variable on the left side of the plus sign is the variable that is retained and has an initial value of 0. The expression on the right side of the plus sign is added to the variable on the left side of the plus sign to create a grand total. The accumulating variable, totsal, is reset back to 0 when you encounter a new BY group value (First.Fname is true). To output just the totals for each BY group, use the explicit OUTPUT statement when you reach the last occurrence of each Fname value.

You can learn about the MERGE statement, the BY statement and match-merging in Combining SAS Data Sets.

35.The contents of the SAS data set Sasdata.Group are listed below.

name age Janice 10 Henri 11 Michele 11 Susan 12

The following SAS program is submitted using the Sasdata.Group data set as input:

libname sasdata 'SAS-data-library'; data group;

set sasdata.group;

file 'file-specification'; put name $15. @5 age 2.; run;

Which one of the following describes the output created? a. a raw data file only

SAS中文论坛网站http://www.mysas.net SAS中文论坛FTP站ftp://mysas.vicp.net

SAS base 50题 训练题(含答案及解析) 

28.ThefollowingSASprogramissubmitted:odshtmlfile='newfile.html';procprintdata=sasuser.houses;run;procmeansdata=sasuser.houses;run;procfreqdata=s
推荐度:
点击下载文档文档为doc格式
5mpqt0nssl555jd3wygd
领取福利

微信扫码领取福利

微信扫码分享