EZ Study

Actuarial Biology Chemistry Economics Calculators Confucius Engineer

SAS Programing Certification Exam
Practice Questions & Answer set-45

Practice Question 215

data x;
set a;
length name $ 5;     retain name 'David';
Click to Get Those Highly Recommended SAS Programmers' Books
do i=1 to 5;     initial = substr(name,1,1);
if initial .ne. 'D' then delete;   run;

How many times is this data step executed based on the datasets below?

data a
name age
Bob   35
Jason 57
John  79

data b
name  age
Bob    2
Dawn  4

data c
name   age
Dawn   30
Bob     35
Jill        40
Jason    45
deb       50

Pick the answer-
a) 2     b) 3     c) 5     d) 10

The Data set has 3 observations.

Practice Question 216

The following program is submitted:

data numrecords;
infile cards dlm=',';
input agent1 $ agent2 $ agent3 $;
; run;

What is the value for the variable named Agent2 in the second observation?

a. brown     b. spencer     c. ' ' (missing character value)
d. There is no value because only one observation is created.

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.

Practice Question 217

A raw data file is listed below.
The following SAS program is submitted using the raw data file above as input:
data employeestats;
input name $ age weight;
Which of the following INFILE statements completes the program and accesses the data correctly?
a. infile 'file-specification' pad;   b. infile 'file-specification' dsd;

c. infile 'file-specification' dlm=',';   d. infile 'file-specification' missover;
The following output is desired:
name age weight
Jose   47  210
Sue     .    108

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.

Related links:

Continue to SAS Practice Exam Question Answer Set-46   SAS interview Questions Answers
Back to SAS Practice Exam Question Answer Set-44   SAS Tutorial   Statistics Tutorial