SAS BASE CERTIFICATION QUESTIONS AND ANSWERS - PART 3 OF 4

The following is a list of questions that can help you to crack Base SAS certification exam.

Previous Two Parts


Q21. The following SAS program is submitted:

data work.one;
x = 3;
y = 2;
z = x ** y;
run;

Which one of the following is the value of the variable Z in the output data set?
A. 6
B. 9
C. . (missing numeric value)
D. The program fails to execute due to errors.

Answer: B.

** = exponentiation
X**Y raise X to the power of Y
So 3 to the power of 2 = 9



Q22. The following SAS program is submitted:

data work.new;
length word $7;
amount = 7;
if amount = 5 then word = 'CAT';
else if amount = 7 then word = 'DOG';
else word = 'NONE!!!';
amount = 5;
run;

Which one of the following represents the values of the AMOUNT and WORD variables?

A. amount word
5 DOG

B. amount word
5 CAT

C. amount word
7 DOG

D. amount word
7 ' ' (missing character value)

Answer : A. When SAS reads in the iterations in sequence, it first writes 7 to the variable 'amount' in PDV. Then it reads through the condition and writes 'DOG' for variable 'word' in PDV. Then it again encounters the value 5 and writes to 'Amount' in PDV.



Q23. The following SAS program is submitted:
data _null_;
set old;
put sales1 sales2;
run;
Where is the output written?

A. the SAS log
B. the raw data file that was opened last
C. the SAS output window or an output file
D. the data set mentioned in the DATA statement

Answer : A.


Q24. The following SAS program is submitted:

data work.report;
set work.sales_info;
if qtr(sales_date) ge 3;
run;

The SAS data set WORK.SALES_INFO has one observation for each month in the year 2000 and the variable SALES_DATE which contains a SAS date value for each of the twelve months.

How many of the original twelve observations in WORK.SALES_INFO are written to the WORK.REPORT data set?

Answer : C. The qtr (quarter) values of each of the months (July through December) 7,8,9,10,11,12 is 3,3,3,4,4,4..Therefore 6 obs are included in the final dataset.



Q25. The following SAS DATA step is submitted:

data sasdata.atlanta sasdata.boston work.portland work.phoenix;
set company.prdsales;
if region = 'NE' then output boston;
if region = 'SE' then output atlanta;
if region = 'SW' then output phoenix;
if region = 'NW' then output portland;
run;

Which one of the following is true regarding the output data sets?
A. No library references are required.
B. The data sets listed on all the IF statements require a library reference.
C. The data sets listed in the last two IF statements require a library reference.
D. The data sets listed in the first two IF statements require a library reference.

Answer : D. The datasets in the first two IF statements require "sasdata" libref.


Q26. The following SAS program is submitted:

proc sort data=work.employee;
by descending fname;

proc sort data=work.salary;
by descending fname;

data work.empdata;
merge work.employee work.salary;
by fname;
run;

Which one of the following statements explains why the program failed execution?

A. The SORT procedures contain invalid syntax.
B. The merged data sets are not permanent SAS data sets.
C. The data sets were not merged in the order by which they were sorted.
D. The RUN statements were omitted after each of the SORT procedures.

Answer : C. The two proc sorts are arranged in descending order. However, the merge is in ascending order. Hence, the two data sets won't be merged.

In merge if you choose to sort by descending then you must use descending with merge statement otherwise it will not merge because of reason ( C ). It does not matter if you sort by ascending order.



Q27. Which one of the following is true of the SUM statement in a SAS DATA step program?

A. It is only valid in conjunction with a SUM function.
B. It is not valid with the SET, MERGE and UPDATE statements.
C. It adds the value of an expression to an accumulator variable and ignores missing values.
D. It does not retain the accumulator variable value from one iteration of the SAS DATA step to the next.

Answer : C.



Q28. The SAS data sets WORK.EMPLOYEE and WORK.SALARY are listed below:

WORK.EMPLOYEE
fname age
Bruce 30
Dan 40
Dan 25000

WORK.SALARY
fname salary
Bruce 25000
Bruce 35000

The following SAS program is submitted:

data work.empdata;
merge work.employee work.salary;
by fname;
totsal + salary;
run;

How many variables are output to the WORK.EMPDATA data set?
A. 3
B. 4
C. 5
D. No variables are output to the data set as the program fails to execute due to errors.

Answer : B. The variables are: Fname, age, salary and totsal.
Note: Obs will not be counted here.



Q29. The following SAS program is submitted:
data work.sets;
do until (prod gt 6);
prod + 1;
end;
run;

Which one of the following is the value of the variable PROD in the output data set?
A. 5
B. 6
C. 7
D. 8

Answer : C. Because of prod + 1 statement, SAS compiler will assume a retain prod 0; statement.

First loop => prod = 1 => (1 gt 6) => false, loop continues
Second loop => prod = 2 => (2 gt 6) => false, loop continues
.....
last loop => prod = 7 => (7 gt 6) => true, do until loop exits and pdv writes prod value of 7 to output dataset.



Q30. Which of the following is not an error identified during the compilation phase?

A) Quotation marks are unbalances
B) No RUN statement in the step
C) An option is invalid
D) Semicolons are missing in statements 

Answer :  B.

Prev Part : Part 2 : SAS Base Certification Questions and Answers
Next Part : Part 4 : SAS Base Certification Questions and Answers
Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

5 Responses to "SAS BASE CERTIFICATION QUESTIONS AND ANSWERS - PART 3 OF 4"

  1. On Question 26, where the program is trying to merge two datasets that have been sorted by 'descending fname', the answers cover possibilities assuming that the merge WILL fail, but in fact whether or not it fails is data-dependent, and the merge MAY work.

    If the work.employee dataset, regardless of how many records it has, has only a single value for fname (e.g., 'Roberto'), and the work.salary dataset, regardless of how many records it has, has only a single value for fname (e.g., 'Lei-Lei'), then sort order Descending equals sort order Ascending and the merge works without an error, from a syntactic point of view. (I'd argue that many-to-many merges in SAS are almost always logically incorrect, but that's not the question here.)

    If each dataset has zero or one record, the merge will ALWAYS work without producing any error messages.

    Doug Dame
    Imagine Health

    ReplyDelete
  2. First I would like to mention the questionnaire has been prepared in a good manner and the answers have been explained well.

    On question 24 you have missed the options. Please add them. Thanks

    ReplyDelete
  3. very nice work brother...helped me a lot. thank you

    ReplyDelete
  4. hi

    Nice post!!!

    Just a quick feedback.. for the below question

    Q28. The SAS data sets WORK.EMPLOYEE and WORK.SALARY are listed below:

    WORK.EMPLOYEE
    fname age
    Bruce 30
    Dan 40
    Dan 25000

    WORK.SALARY
    fname salary
    Bruce 25000
    Bruce 35000

    I think that the last observation from WORK.EMPLOYEE should be moved to WORK.SALARY.

    Thanks again... Keep up the good work.

    ReplyDelete

Next → ← Prev