EZ Study

Actuarial Biology Chemistry Economics Calculators Confucius Engineer
Physics
C.S.

SAS Programing Certification Exam
Practice Questions & Answer set-28

Practice Question 139

The following SAS program is submitted:
data work.test;     Author = 'Agatha Christie';

First = substr(scan(author,1,' ,'),1,1); run;


Which one of the following is the length of the variable FIRST in the output data set?
A. 1     B. 6     C. 15     D. 200



Answer is D. By default, scan function returns a 200 characters length variable.

Practice Question 140

Which one of the following is true of the RETAIN statement in a SAS DATA step program?
A. It can be used to assign an initial value to _N_ .
B. It is only valid in conjunction with a SUM function.
C. It has no effect on variables read with the SET, MERGE and UPDATE statements.
D. It adds the value of an expression to an accumulator variable and ignores missing values.


Answer is C. Some people may argue for D, but "ignore missing values" is vague, not that sure; C is for sure correct.

Practice Question 141

A raw data file is listed below:
--------10-------20-------30
1901 2
1905 1
1910 6
1925 .
1941 1
The following SAS program is submitted and references the raw data file above:
data coins;
infile 'file-specification';
input year quantity;

run;
Which one of the following completes the program and produces a non-missing value for the variable TOTQUANTITY in the last
observation of the output data set?
A. totquantity + quantity;
B. totquantity = sum(totquantity + quantity);
C. totquantity 0;
sum totquantity;
D. retain totquantity 0;
totquantity = totquantity + quantity;


Answer is A. If you try the program by yourself, you will get missing value in the last observation from D.

Practice Question 142

A raw data file is listed below:
--------10-------20-------30
squash 1.10
apples 2.25
juice 1.69
The following SAS program is submitted using the raw data file above:
data groceries;
infile 'file-specification';
Click to Get Those Highly Recommended SAS Programmers' Books
input item $ cost; .... run;
Which one of the following completes the program and produces a grand total for all COST values?
A. grandtot = sum cost;
B. grandtot = sum(grandtot,cost);
C. retain grandtot 0;
grandtot = sum(grandtot,cost);
D. grandtot = sum(grandtot,cost);
output grandtot;


Answer is C.

Related links:

Continue to SAS Practice Exam Question Answer Set-29   SAS interview Questions Answers
Back to SAS Practice Exam Question Answer Set-27   SAS Tutorial   Statistics Tutorial