2024年5月5日发(作者:)

SAS认证考试样题

1.A raw data file is listed below.

1---+----10---+----20---+---

son Frank 01/31/89

daughter June 12-25-87

brother Samuel 01/17/51

The following program is submitted using this file as input:

data ;

infile 'file-specification';

run;

Which INPUT statement correctly reads the values for the variable

Birthdate

as SAS

date values?

a.

input relation $ first_name $ birthdate date9.;

input relation $ first_name $ birthdate mmddyy8.;

b.

input relation $ first_name $ birthdate : date9.;

c.

input relation $ first_name $ birthdate : mmddyy8.;

d.

Correct answer: d

An informat is used to translate the calendar date to a SAS date value. The date values are

in the form of two-digit values for month-day-year, so the MMDDYY8. informat must be

used. When using an informat with list input, the colon-format modifier is required to

correctly associate the informat with the variable name.

You can learn about

informats in Reading Date and Time Values

the colon-format modifier in Reading Free-Format Data.

2.A raw data file is listed below.

1---+----10---+----20---+---

Jose,47,210

Sue,,108

The following SAS program is submitted using the raw data file above as input:

data employeestats;

input name $ age weight;

run;

The following output is desired:

name

age

weight

Jose

47

210

Sue

.

108

Which of the following INFILE statements completes the program and accesses the data

correctly?

a.

infile 'file-specification' pad;

b.

infile 'file-specification' dsd;

SAS中文论坛网站

SAS中文论坛FTP站ftp://

SAS认证考试样题

c.

infile 'file-specification' dlm=',';

d.

infile 'file-specification' missover;

Correct answer: b

The PAD option specifies that SAS pad variable length records with blanks. The

MISSOVER option prevents SAS from reading past the end of the line when reading free

formatted data. The DLM= option specifies the comma as the delimiter; however,

consecutive delimiters are treated as one by default. The DSD option correctly reads the

data with commas as delimiters and two consecutive commas indicating a missing value

like those in this raw data file.

You can learn about

the PAD option in Reading Raw Data in Fixed Fields

the MISSOVER option in Creating Multiple Observations from a Single

Record

the DLM= option and the DSD option in Reading Free-Format Data.

following program is submitted:

data numrecords;

infile cards dlm=',';

input agent1 $ agent2 $ agent3 $;

cards;

jones,,brownjones,spencer,brown

;

run;

What is the value for the variable named

Agent2

in the second observation?

a.

b.

c.

d.

brown

spencer

' ' (missing character value)

There is no value because only one observation is created.

Correct answer: d

The CARDS statement enables you to read instream data. Any number of consecutive

commas are considered to be a single delimiter as a result of the DLM= option, and the

length of each variable defaults to 8 bytes. Therefore, the values jones, brownjon, and

spencer are assigned to

Agent1

,

Agent2

, and

Agent3

, respectively, for the first

observation. The rest of the data on the record is not read by the INPUT statement and is

not output to the data set.

You can learn about

the CARDS statement in Creating SAS Data Sets from Raw Data

the default length of variables in Reading Free-Format Data.

SAS中文论坛网站

SAS中文论坛FTP站ftp://