EZ Study

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

SAS Programing Certification Exam
Practice Questions & Answer set-1

Practice Question 1

The following SAS program is submitted:

data work.total;
set work.salary(keep = department wagerate);
by department; if first.department then payroll = 0;
Click to Get Those Highly Recommended SAS Programmers' Books
payroll + wagerate;
if last.department;     run;

The SAS data set named WORK.SALARY contains 10 observations for each department, currently ordered by DEPARTMENT.

Which one of the following is true regarding the program above?
A. The BY statement in the DATA step causes a syntax error.
B. FIRST.DEPARTMENT & LAST.DEPARTMENT are variables in WORK.TOTAL dataset.

C. The values of the variable PAYROLL represent the total for each department in the WORK.SALARY data set.
D. The values of the variable PAYROLL represent a total for all values of WAGERATE in the WORK.SALARY data set.

Answer: C. For every BY group we get the sum of wagerate in the Payroll variable for each department.

Practice Question 2

The following SAS program is submitted:

libname sasdata 'SAS-data-library';
data test;
set sasdata.chemists (keep = job_code);
if job_code = 'chem3' then description = 'Senior Chemist';
run;

The variable JOB_CODE is a character variable with a length of 6 bytes.

Which one of the following is the length of the variable DESCRIPTION in the output data set?

A. 6 bytes     B. 8 bytes     C. 14 bytes     D. 200 bytes

Answer: C; At compilation time, SAS finds the occurrence of the variable DESCRIPTION for the first time and sets its length as 14 bytes.

Practice Question 3

The following SAS program is submitted:

data work.accounting;
set work.dept1 work.dept2;
run;

A character variable named JOBCODE is contained in both the WORK.DEPT1 and WORK.DEPT2 SAS data sets. The variable JOBCODE has a length of 5 in the WORK.DEPT1 data set and a length of 7 in the WORK.DEPT2 data set.
Which one of the following is the length of the variable JOBCODE in the output data set?

A. 5     B. 7     C. 8     D. 12

Since SAS sees the variable Job_code in DEPT1 for the first time of length of 5 Bytes. it sets the length to be 5. All the values that are read from DEPT2 are truncated to Chars.

Practice Question 4

The following SAS DATA step is submitted:

data work.accounting;
set work.department;
length jobcode $ 12;
run;
The WORK.DEPARTMENT SAS data set contains a character variable named JOBCODE with a length of 5. Which one of the following is the length of the variable JOBCODE in the output data set?

A. 5     B. 8     C. 12
D. The length cannot be determined as the program fails to execute due to errors.

Answer: A. Since SAS sees the jobcode to be 5 chars before it reads in the length statement. If the length statement were before the set statement. then this would have set the length to 12 chars.

Practice Question 5

Which one of the following SAS statements renames two variables?
A. set work.dept1 work.dept2(rename = (jcode = jobcode) (sal = salary));
B. set work.dept1 work.dept2(rename = (jcode = jobcode sal = salary));
C. set work.dept1 work.dept2(rename = jcode = jobcode sal = salary);
D. set work.dept1 work.dept2(rename = (jcode jobcode) (sal salary));

Answer: B. Check the syntax of rename= dataset option

Related links:

Continue to SAS Practice Exam Question Answer Set-2   SAS interview Questions Answers
Back to SAS Certification Exam Tutorial Homoe   SAS Tutorial   Statistics Tutorial