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

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

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

Which one of the following is produced as output?

a. the list of all data set names in the Sasuser library only b. the descriptor portion of the data set named Sasuser._All_

c. the descriptor portion of every data set in the Sasuser library only

d. the list of data set named in the Sasuser library plus the descriptor portion of every data set in the Sasuser library. Correct answer: a

You can use the CONTENTS procedure to create SAS output that describes the contents of a library. _ALL_ requests a listing of all files in the library, and NODS suppresses the printing of detailed information about each file in the output.

You can learn about the CONTENTS procedure in Referencing Files and Setting Options.

45.The following SAS program is submitted:

data work.test;

length city $20; city='Paris';

city2=trim(city); run;

Which one of the following is the length of the city2 variable? a. 5 b. 6 c. 8 d. 20

Correct answer: d

The LENGTH statement specifies that the variable city has a length of 20 characters. The TRIM function in the assignment statement for city2 removes trailing blanks from the value. However, the length of the city2 variable is set to 20 because city has a length of 20, and SAS pads the trimmed value with extra blanks. You can learn about

? ?

the LENGTH statement in Reading Free-Format Data

the TRIM function in Transforming Data with SAS Functions.

46. A raw data record is listed below.

1---+----10---+----20---+--- $23,456 750

The following SAS program is submitted:

data bonus;

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

infile 'file-specification'; input salary $ 1-7 raise 9-11; run;

Which one of the following statements completes the program and adds the values of salary and raise to calculate the expected values of the newsalary variable? a. newsalary=salary + raise;

b. newsalary=put(salary,comma7.) + raise; c. newsalary=input(salary,comma7.) + raise;

d. newsalary=put(salary,comma7.) + put(raise,3.); Correct answer: c

You must convert the value of salary from character to numeric in order to perform an arithmetic function on it. You use the INPUT function to convert a character value to a numeric value.

You can learn about the INPUT function in Transforming Data with SAS Functions. 47.The following SAS program is submitted:

data work.travel; do i=1 to 6 by 2; trip + i; end; run;

Which one of the following is the value of the variable trip in the output data set? a. 2 b. 3 c. 9 d. 10

Correct answer: c

The sum variable in a sum statement is automatically set to 0 before the first observation is read from the data set. The sum variable in the statement above is increased by the value of i on each iteration of the DO loop; the value of i is set to 1 on the first iteration of the DO loop and increases by 2 on each additional iteration until it is greater than 6. Therefore, the value of Trip is equal to 0 + 1 + 3 + 5, which is 9. You can learn about

? ?

the sum statement in Creating and Managing Variables DO loops in Generating Data with DO Loops. The following SAS program is submitted:

48.

proc report data=survey nowd; column age choice1;

define choice1/display;

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

run;

Which one of the following DEFINE statements completes the program and displays values of the variable Age in ascending order? a. define age/sort; b. define age/order;

c. define age/sort by age; d. define age/order by age; Correct answer: b

You use a DEFINE statement to describe how to order and use variables in your report. To specify Age as an order variable, you use the ORDER usage option in the DEFINE statement. An order variable orders the detail rows in a report according to their formatted values. By default, the order is ascending.

You can learn about the DEFINE statement and order variables in Creating Enhanced List and Summary Reports.

49.Which one of the following statements is true when SAS encounters a data error? a. The execution phase is stopped, and a system abend occurs.

b. A missing value is assigned to the appropriate variable, and execution continues. c. The execution phase is stopped, and a SAS data set is created with zero observations. d. A missing value is assigned to the appropriate variable, and execution stops at that point.

Correct answer: b

Unlike syntax errors, invalid data errors do not cause SAS to stop processing a program. SAS handles invalid data errors by assigning a missing value to the appropriate variable and writing a message to the SAS log.

You can learn about how SAS handles invalid data errors in Creating SAS Data Sets from Raw Data.

50.The following SAS program is submitted:

data test;

input country $8. date mmddyy10.; cards;

Germany 12/31/2000 France 01/32/2001 ; run;

Which one of the following is the value of the variable _ERROR_ when the variable _N_ has a value of 2? a. 0 b. 1 c. true d. false

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

Correct answer: b

_N_ and _ERROR_ are automatic variables that can be used for DATA step processing but that are not written to the output data set. _N_ counts the number of times that the DATA step begins to execute, and _ERROR_ signals the occurrence of an error that is caused by the data during execution. A value of 0 indicates no error while a value of 1 indicates one or more errors. In the program above, the value for date in the second observation is invalid.

You can learn about the automatic variables _N_ and _ERROR_ in Understanding DATA Step Processing.

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

5mpqt0nssl555jd3wygd
领取福利

微信扫码领取福利

微信扫码分享