complete solutions
Q1. 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 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. - correct answer ✔✔ C. For every BY group we get the sum of wagerate
in the Payroll variable for each department.
The following SAS program is submitted:
data test;
set sasuser.employees;
if 2 le years_service le 10 then amount = 1000;
,else if years_service gt 10 then amount = 2000;
else amount = 0;
amount_per_year = years_service / amount;
run;
Which one of the following values does the variable AMOUNT_PER_YEAR contain if an
employee has been with the company for one year?
A. 0
B. 1000
C. 2000
D. . (missing numeric value) - correct answer ✔✔ Answer : D (missing). It returns missing value
as amount will be 0. SAS Log: NOTE: Mathematical operations could not be performed at the
following places. The results of the operations have been set to missing values.
The contents of the raw data file NAMENUM are listed below:
--------10-------20-------30
Joe xx
The following SAS program is submitted:
data test;
infile 'namenum';
input name $ number;
run;
Which one of the following is the value of the NUMBER variable?
A. xx
B. Joe
C. . (missing numeric value)
D. The value can not be determined as the program fails to execute due to errors. - correct
answer ✔✔ Answer : C. It is because number is defined as a numeric variable so it is expecting a
numeric value but it reads xx, so number will be a missing value.
,How many of the following variable names will not produce errors in an assignment statement?
variable
var
1variable
var1
#var
_variable#
A. 0
B. 1
C. 3
D. 6 - correct answer ✔✔ C ; variable var var1. A variable cannot start with numeric or special
characters except _. You also cannot use special characters anywhere in the name either though
numeric values are allowed.
Suppose the variable 'Unit_Cost_Price' (numeric) contains both missing and non missing values.
What would the following code return?
proc sort data=ecsql1.price_list;
by Unit_Cost_Price;
run;
A. A new dataset work.price_list is created with Unit_Cost_Price sorted in ascending order with
missing values at the bottom of the dataset
B. The dataset ecsql1.price_list is sorted with Unit_Cost_Price sorted in descending order with
missing values at the bottom of the dataset
C. A new dataset work.price_list is created with Unit_Cost_Price sorted in descending order
with missing values at the top of the dataset
D. The dataset ecsql1.price_list is sorted with Unit_Cost_Price sorted in ascending order with
missing values at the top of the dataset - correct answer ✔✔ D. It is because missing values are
considered as lowest values (ascending order; they will be top of the data set)
, The following SAS program is submitted:
dta work.il_corn;
set corn.state_data;
if state = 'Illinois';
run;
The keyword "data" is misspelled above. What happens to this program during the compilation
phase assuming "corn" is a valid libref?
A. The program fails due to syntax errors
B. The DATA step compiles but doesn't execute
C. The DATA step compiles and executes
D. None of the above - correct answer ✔✔ C. It compiles and executes as SAS assumed that the
'dta' was data. But it leaves a warning in log window.
The log shows the following warning :
WARNING 1-322: Assuming the symbol DATA was misspelled as dta.141 run;
Which of the following is a valid statement about the VALUE range in the PROC FORMAT
procedure? It cannot be...
A. A single character or numeric value
B. A range of character values
C. A list of unique values separated by commas
D. A combination of character and numeric values - correct answer ✔✔ D.
How many of the following statistics that PROC MEANS computes as default statistics?
Standard deviation
RangeCount
Minimum valueVariance