SAS Programing Certification Exam
Practice Questions & Answer set-45
Practice Question 215
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;
How many times is this data step executed based on the datasets below?
Pick the answer-
The Data set has 3 observations.
Practice Question 216
The following program is submitted:
infile cards dlm=',';
input agent1 $ agent2 $ agent3 $;
What is the value for the variable named Agent2 in the second observation?
c. ' ' (missing character value)
d. There is no value because only one observation is created.
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:
input name $ age weight;
Which of the following INFILE statements completes the program and accesses the data
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
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.
Continue to SAS Practice Exam Question Answer Set-46
SAS interview Questions Answers
Back to SAS Practice Exam Question Answer Set-44