Base SAS Certification Questions Series - Part 1

The Global SAS certification exam is administered by SAS and Pearson VUE together. There are 60-65 multiple choice questions in Base SAS certification exam and candidate must achieve 70% score to pass multiple choice questions in  110 minutes.

We are starting a series of articles to help you prepare for this examination. Covering a few questions in first article of the series along with their explanation.

Q1. The following SAS program is submitted:


Data work.staff;
JobCategory = 'FA';
JobLevel = '1';
Jobcategory =    Jobcategory || JobLevel ;
run;

Which one of the following is the value of the variable Jobcategory in the output data set?

A. FA
B. FA1
C. FA 1
D. ' ' (missing character value)

Answer of the question is highlighted.

Explanation: 

In PDV(Program Data Vector) first the variables Jobcategory will be created with the length of (2 bytes / 2 characters) executing first statement (JobCategory = ‘FA’).

So, the length of variable Jobcategory  will remain the same within this data step.  So even when the third statement is concatenating the "FA" and "1" values, the variable Jobcategory  can't accommodate string of length 3,  hence remains FA.

For better explanation try following code.

Data work.staff;
JobCategory = 'FA';
JobLevel = '1';
Jobcategory =   JobLevel || Jobcategory;
run;

Jobcategory  now becomes "1F"   ....  I hope you  have got the crux.

Q2. The following SAS program is submitted:


Data work.total;
Set work.salary(keep = department wagerate);
By department;
If first.department then payroll = 0;
Payroll + wagerate;
If last.department;
run;

The SAS data set WORK.SALARY, currently ordered by DEPARTMENT, contains 100 observations for each of 5 departments. Which one of the following represents how many observations the WORK.TOTAL data set contains?
A. 5
B. 20
C. 100
D. 500

Answer of the question is highlighted.

Explanation: 

Sometimes in examinations, questions are intentionally made lengthy and hence confusing. Classical example of the same is the above question.

Try to identify the key statement in such cases. Here If Last.department  statement is the key.

If Last.department  and By department combo gets  the last occurrence of each of the 5 departments. Hence only 5 observations would be left.


Enjoy reading our other articles and stay tuned with ...

Kindly do provide your feedback in the 'Comments' Section and share as much as possible.