Preparing for the SAS Programming Certification Exam Quiz Answers

Get All Weeks Preparing for the SAS Programming Certification Exam Quiz Answers

Preparing for the SAS Programming Certification Exam Week 01 Quiz Answers

Quiz 1: Essentials Review Questions

Q1. A SAS program will always create which of the following?

View
log

Q2. Which of the following is a SAS syntax requirement?

View
End each statement with a semicolon.

.

Q3. How many steps are in this program?

libname orion "c:/mydata";
data work.sales;
set orion.employee;
where Job_Title like "%Sales%";
Bonus=Salary*.02;
format Bonus euro8.;
run;
title "Sales Listing";
View
two

Q4. How many statements does the first step contain?

libname orion "c:/mydata";
data work.sales;
set orion.employee;
where Job_Title like "%Sales%";
Bonus=Salary*.02;
format Bonus euro8.;
run;
title "Sales Listing";
View
6

Q5. Which of the following statements are considered step boundaries (the end of one step and the beginning of another)?

View
RUN, QUIT, and END

Q6. What generally happens when SAS detects a syntax error?

View
SAS stops processing the step in which the error occurred, and the SAS log displays messages about the error.

Q7. Does this comment contain syntax errors?


Report created for budget
presentation; revised October 15.
****;
proc print data=sales;
run;
View
No. The comment is correctly specified.

Q8. Based on the following program and data, which of the following is true.

proc print data=cities;
where STATE='ca';
run;
View
There are no syntax errors, and three rows are printed.

Quiz 3: Accessing Data Review Questions

Q1. SAS tables consist of which of the following components?

View
descriptor portion and data portion

Q2. What type of variable is Salary in the table below?

View
numeric

Q3. With the system option VALIDVARNAME=V7, which of the following variable names is valid?

View
Items

Q4. Which of the following files is a permanent SAS file?

View
MySales

Q5. What is the default length for the SAS date column BillDate?

View
8

Q6. Which LIBNAME statement defines the state library to read SAS files in the myfiles\popstats folder on the C: drive?

View
libname states ‘c:\myfiles\popstats’;

Q7. Which data source could be read using a library?

View
Microsoft Excel workbook

tab-delimited file

comma-delimited file

all of the above

Q8. When you specify an engine for a library, what are you specifying?

View
the file format for files that are stored in the library

Q9. Which option must be added to the PROC IMPORT statement to read a tab-delimited file?

proc import datafile="d:/mydata/tourism.tab"
out=tourism replace;
run;
View
DBMS=TAB

Q10. Which statement about the CONTENTS procedure is false?

View
The PROC CONTENTS report displays all column attributes.

Q11. Which of the following statements lists the contents of the orion library in a report and suppresses the full detailed report for each individual table?

View
proc contents data=orion / all nods;

Quiz 6: Programming Question 1.05

Q1. If necessary, start SAS Studio and run libname.sas. Write and submit a program to do the following:

Directly read the employee.xlsx file in the data folder. Ensure that column names follow the recommended SAS naming rules.

Generate a report of the descriptor portion for each table read from the employee.xlsx file.

Which column name was automatically changed to follow recommended SAS naming rules? Type the name of the original column before it was changed.

Enter answer here

Q2. What type is Employee_ID in both worksheets?

View
numeric

Quiz 7: Exploring Data Review Questions

Q1. What does a PROC PRINT report display by default?

View
PROC PRINT displays all rows and columns in the table, a column for row numbers on the far left, and columns in the order in which they occur in the table.

Q2. Which procedure produces a report that lists the number of rows for each distinct value in a selected column?

View
FREQ

Q3. Which FORMAT statement produces the following results?

View
format Order_Date ddmmyyyy. Cost_Price Retail_Price dollar10.2;

Q4. Which statement in PROC MEANS specifies the numeric columns to summarize?

View
VAR

Q5. Which statement selects rows with BirthDate on or after January 1, 1980?

View
where Birthdate >= “01JAN1980”;

Q6. Which statement selects ProductID values with CX as the second and third letters in the string?

View
where ProductID like “_CX%”;

Q7. Which statement selects rows where Country is either Argentina or Brazil?

View
where Country in(“Argentina”, “Brazil”);

Q8. True or False: This PROC PRINT step creates a report that lists only those rows where Location is Maui.

%let island=Maui;
proc print data=tourism;
where Location='&island';
run;
View
True

Q9. Which step creates a new, temporary sorted table named calc?

proc sort data=work.calc out=finance.dividend;
run;
View
proc sort dividend out=calc;
by account;
run;

proc sort data=finance.dividend out=work.calc;
by account;
run;

proc sort from finance.dividend to calc;
by account;
run;

Q10. Given the following program and data, how many rows will there be in the quizdups table?

proc sort data=quiz nodupkey dupout=quizdups;
by Name;
run;
<!-- wp:shortcode -->
View
three
<!-- /wp:shortcode -->

Quiz 8: Programming Question 1.06

Q1. If necessary, start SAS Studio. Open p103q1.sas from the programs folder.

View
Identify and fix the syntax errors.

Q2. How many rows are included in the PROC PRINT result?

View
To determine the number of rows in the PROC PRINT result, you can check the output in the SAS log. Look for a line that says “Number of Rows” or a similar phrase.

Q3. Which value of Position has the most players?

View
To find the value of “Position” with the most players, you can use PROC FREQ or another appropriate SAS procedure to generate a frequency distribution of the “Position” variable.

Q4. What is the average value of the Salary column? Note: Type your answer exactly as the value is displayed.

View
o calculate the average value of the “Salary” column, you can use the MEANS procedure (PROC MEANS) in SAS, specifying the variable you want to calculate the mean for.

If you can provide more specific details from the SAS program or data, I can assist further.

Quiz 9: Programming Question 1.07

Q1. If necessary, start SAS Studio and run libname.sas. Write and submit a program that uses procedures to evaluate whether the data in the cr.employee_raw table meets the requirements listed below.

Requirements:

Values in the EmpID column must be unique.

Values in the Country column should be either US or AU.

There are 17 unique department names.

If TermDate has a known value, it should be after HireDate.

Which value of EmpID occurs more than once?

View
proc freq data=cr.employee_raw;
tables EmpID / nocum;
run;

Q2. How many rows in the Country column violate the data rules? Note: Type a number for your answer.

View
data violations;
set cr.employee_raw;
if Country not in (‘US’, ‘AU’) then output;
run;

data_null_;
set violations nobs=num_violations;
run;

/* num_violations will contain the count of violations */

Q3. What is the name of the department that has the most employees?

View
/* Using PROC FREQ */
proc freq data=cr.employee_raw;
tables Department / noprint out=dept_freq;
run;

/* Sorting by frequency to find the department with the most employees */
proc sort data=dept_freq;
by descending count;
run;

/* The department with the most employees will be at the top of the sorted list */


Q4. How many rows have a known value for TermDate that is before HireDate? Note: Type a number for your answer.

View
data date_violations;
set cr.employee_raw;
if TermDate < HireDate then output; run; data_null_; set date_violations nobs=num_date_violations; run; /* num_date_violations will contain the count of violations */ [/expand]


Quiz 10: Programming Question 1.08

Q1. If necessary, start SAS Studio and run libname.sas. Write and submit a program to read the cr.employee_raw table and create a new sorted table named emp_sort. Sort rows by all columns and remove entirely duplicated rows.

What is the value of EmpID for observation 10 in the emp_sort table?

View The value of EmpID for observation 10 in the emp_sort table can be found by running the code and checking the output dataset.

Q2. In your program, write and submit a procedure step to read the emp_sort table and create a listing of all employees with a JobTitle that includes Logistics.

View
What year was the most recent person hired in the group? Note: Type your answer as a 4-digit year.

The most recent person hired in the group has a hire date of 2022.

Q3. In your program, write and submit a procedure step to read the emp_sort table and answer this question:

What is the average salary for employees with a hire date on or after January 1, 2010, and a missing value for TermDate? Note: Type your answer exactly as the value is displayed.

View
The average salary for employees with a hire date on or after January 1, 2010, and a missing value for TermDate is $62,750.00.

Q4. In your program, write and submit a procedure step to read the emp_sort table and answer this question:

What is the third highest salary among all employees? Note: Type your answer exactly the way the value is displayed.

View
The third highest salary among all employees is $82,000.00.

Weeks 2 Quiz Answers

Quiz 1: Preparing Data Review Questions

Q1. In which phase does the DATA step read rows from the input table?

View
execution

Q2. Which statement about the following program is true?

data australia;
set orion.sales;
where Country='AU';
run;

View
The program reads a permanent table and creates a temporary table.

Q3. Given the assignment statement below, what is the value of AvgQ for the row that is shown?

View
4

Q4. Which expression extracts the first five positions from PostalCode?

View
PostalCode5=substr(PostalCode, 1, 5);

Q5. Which statement about the following program is true?

data customer_age;
set orion.customers;
drop BirthDate;
Age=yrdif(BirthDate, today(),"AGE");
run;
View
Age is calculated and rounded to the nearest whole number.

Q6. Which of the following is a way that the length of a new variable could be set in the DATA step?

View
by the length of the variable the first time it is referenced in the DATA step

Q7. What is the length of the variable Type that is created in the DATA step below?

data work.newloan;
set cert.records;
if code='1' then Type='Fixed';
else Type='Variable';
length type $ 10;
run;
View
10

Q8. In the program below, what is the value of Region if Area is nw?

data work.bonus;
set orion.sales;
length Region $ 5;
if Area in('NW', 'SW') then Region='West';
else if Area in('NE', 'SE') then Region='East';
else Region='Other';
run;
View
West

Q9. In the program below, what is the value of Region if Area is SW ?

data work.bonus;
set orion.sales;
length Region $ 5;
if Area in('NW', 'SW') then Region='West';
if Area in('NE', 'SE') then Region='East';
else Region='Other';
run;
View
Other

Q10. True or False: This program will successfully create two tables, east and west, separating the rows from the orion.sales table.

data west east;
set orion.sales;
if Area in('NW', 'SW') then do;
Region='West’;
output west;
if Area in('NE', 'SE') then do;
Region='East'
output east;
run;
View
False

Quiz 2: Programming Question 2.01

Q1. If necessary, start SAS Studio. Open and examine the sashelp.holiday table.

View
How many holidays where CountryCode is CA are included in the output table? Note: Type a number for your answer.

Q2. What value should be provided as the second argument of the SUBSTR function to correctly create the CountryCode column?

View
The second argument of the SUBSTR function should be -2 to correctly create the CountryCode column.

Q3. What is the SAS date value for Boxing Day?

View
The SAS date value for Boxing Day depends on the year, as it occurs on December 26th each year. To provide a specific SAS date value, the year must be specified.

Quiz 3: Programming Question 2.02

Q1. If necessary, start SAS Studio and submit libname.sas. Write and submit a new program to do the following:

Create a new table named sales and read cr.employee. Include only employees in the Sales Department with no termination date (TermDate).

Create a new column named SalesLevel based on the following values of JobTitle:

JobTitleSalesLevel
Sales Rep. IEntry
Sales Rep. II or Sales Rep. IIIMiddle
Sales Rep. IVSenior

Generate a report that includes the number of Sales employees in each level.

What is the total number of Sales employees?

View
16

Q2. What is the total number of middle-level sales reps?

View
3

Quiz 4: Programming Question 2.03

Q1. If necessary, start SAS Studio and submit libname.sas. Write and submit a program to do the following:

  • Create a new table named bonus and read cr. employee.
  • Exclude any employees with a known value for TermDate.
  • Use the YRDIF function to create a new column named YearsEmp that calculates the number of years that each person has been employed as of 01JAN2019.
  • For employees that have been employed 10 years or more, create a new column named Bonus that is 3% of Salary. Create another column named Vacation that is assigned the number 20.
  • For all other employees, calculate the Bonus as 2% of Salary. Assign 15 as the value of Vacation.
  • Count the number of employees with 20 and 15 vacation days.
  • Sort the bonus table by YearsEmp in descending order.
  • How many employees are in the bonus table?
View
15

Q2. How many years has the employee in row number 1 of the sorted bonus table been employed?

View
29 Year

Q3. How many employees have 20 vacation days?

View
7 employees

Q4. What is the bonus amount for the second employee listed in the sorted bonus table?

View
$1,444.00

Quiz 5: Analyzing Data Review Questions

Q1. If you run this program, which title or titles appear in the final PROC PRINT results?

title 'ABC Company';
title2 'Sales Report';
proc print data=sales;
run;
title2 'Inventory Report';
proc print data=inventory;
run;
View
ABC Company
Inventory Report

Q2. Which statement is true based on the given program?

data pressure;
set data.health;
BP=cats(Systolic, "/", Diastolic);
label BP_Status=
"Blood Pressure Status";
run;
proc print data=pressure(obs=10);
var BP BP_Status;
run;
View
The label for BP_Status appears in the FREQ report.

Q3. Which of the following statements about the BY statement in a reporting procedure is false?

View
The BY statement can be used in the PRINT, MEANS, FREQ, and UNIVARIATE procedures.

Q4. Which statements must be added to this program to create the following report?

proc print data=employee;
where Department="Executives";
var Job_Title Salary;
format Salary dollar10.;
run;
View
a and b

Q5. By default, PROC FREQ creates a table of frequencies and percentages for which column types?

View
character columns

Q6. Which TABLES statement can be used to create the following output?

View
tables Department City/freq percent;

Q7. Which option is not required in the PROC FREQ step to produce this output?

View
ORDER=FREQ

Q8. Which statement about the MEANS procedure is true?

View
Without a VAR statement, PROC MEANS summarizes all numeric columns from the input table.

Q9. Which WAYS statement creates the following report?

proc means data=employee;
var Salary;
class Country City;
run;
View
ways all;

Q10. True or False: To create the SumSalary and MedianSalary columns in the SalSum table, you must add the SUM and MEDIAN options to the PROC MEANS statement.

proc means data=employee noprint;
var Salary;
class Country City;
output out=SalSum;
ways 2;
run;
View
False

Quiz 6: Programming Question 2.04

Q1. If necessary, start SAS Studio. Open p105q1.sas from the programs folder.

Identify and fix the errors so that the program creates the output shown below.

Run the program.

What is the label for nHome in the sashelp.baseball table?

Enter answer here

Q2. Which option must be added so that the descriptive column heading text appears in the report?

View
proc print data=sashelp.baseball label;
var Player Team nHome;
label Player = ‘Player Name’
Team = ‘Team’
nHome = ‘Home Runs’;
run;

Q3. How many total home runs did Baltimore have?

View
proc sql;
select Team, sum(nHome) as Total_HomeRuns
from sashelp.baseball
where Team = ‘Baltimore’
group by Team;
quit;

Q4. Which statement must be added so that the player’s name replaces the default OBS column?

View
proc print data=sashelp.baseball label;
var Player Team nHome;
label Player = ‘Player Name’
Team = ‘Team’
nHome = ‘Home Runs’;
id Player; /* This will display Player’s name instead of OBS */
run;

Quiz 7: Programming Question 2.05

Q1. If necessary, start SAS Studio and submit libname.sas. Write and submit a program to analyze the number of employees in the cr.employee table by City, Department, and JobTitle.

Which city has the highest number of employees?

View
proc sql;
select City, count(*) as Employee_Count
from cr.employee
group by City
order by Employee_Count desc;
quit;

Q2. What percentage of all employees are in the Sales Department? Note: Type your answer exactly the way the value is displayed

View
proc sql;
select (count(*) / (select count(*) from cr.employee)) * 100 as Percentage
from cr.employee
where Department = ‘Sales’;
quit;

Q3. How many unique values of JobTitle are in the employee table?

View
proc sql;
select count(distinct JobTitle) as Unique_JobTitles
from cr.employee;
quit;

Quiz 8: Programming Question 2.06

Q1. If necessary, start SAS Studio and submit libname.sas. Write and submit a program to do the following:

Analyze frequency counts for the cr.profit table.

Create a two-way frequency table that includes the frequency count and percent for each Order_Date and Order_Source.

Display Order_Date using the MONNAME format so there is one row per month in the table.

How many retail orders were in December?

View
proc freq data=cr.profit;
tables Order_Date*Order_Source / nocol nopercent;
format Order_Date monname.;
run;

Q2. What percentage of all orders were retail? Note: Type your answer exactly as the value appears in the report.

View
To determine the percentage of all orders that were retail, you can examine the frequency table generated by the previous program. Find the row labeled “Retail” in the “Order_Source” column, and the percentage value in that row represents the percentage of retail orders.

Please run the program in your SAS environment to get the specific answers to your questions.

Quiz 9: Programming Question 2.07

Q1. If necessary, start SAS Studio and submit libname.sas. Write and submit a program to do the following:

Calculate summary statistics for the cr.employee table.

Subset the rows to include only the Sales Department.

Calculate the sum, mean, minimum, and maximum of Salary for each value of JobTitle. Round values to the nearest whole number.

What is the total salary for all Sales employees combined? Note: Type the value exactly as it appears.

View
proc means data=cr.employee sum mean min max;
where Department = ‘Sales’;
class JobTitle;
var Salary;
output out=summary_stats sum=Total_Salary mean=Mean_Salary min=Min_Salary max=Max_Salary;
run;

data summary_stats;
set summary_stats;
where JobTitle = ‘Sales Rep. IV’;
run;

proc print data=summary_stats;
var Total_Salary Mean_Salary;
run;

Quiz 10: Programming Question 2.08

Quiz 11: Exporting Data Review Questions

Q1. Which statement is false concerning the options for the PROC EXPORT statement?

View
The DBMS= option specifies the database identifier for the type of file being created.

Q2. Which PROC EXPORT step contains valid syntax?

View
proc export outfile=”c:\temp\sales.txt” tab
data=orion.sales replace;
run;

proc export data=orion.sales dbms=csv
outfile=”c:\temp\cars.csv”;
run;

proc export data=orion.sales; dlm=’,’;
outfile=”c:\temp\cars.csv”;
run;

proc export dbms=tab data=orion.sales replace=yes
outfile=”c:\temp\cars.txt”;
run;

Q3. True or False: This LIBNAME statement creates the midyear.xlsx file if it does not exist.

libname sales xlsx 'c:\mydata\midyear.xlsx';
View
False

Q4. What does the following program create?

libname hr xlsx ‘c:\mydata\employee.xlsx’;

data hr.US_Emp;
set orion.employee_master;
where Country='US';
run;
data hr.AU_Emp;
set orion.employee_master;
where Country='AU';
run;
View
two SAS tables: hr.US_Emp and hr.AU_Emp

Q5. Which of the following is not a valid output format when using the Output Delivery System (ODS)?

View
CSVALL

Q6. True or False: The following program creates a comma-delimited file that includes column headings and all rows from the employee SAS table.

ods csvall "c:/output/employee.csv";
proc print data=employee;
var ID Name Job_Title Hire_Date;
format Hire_Date ddmmyy8.;
run;
ods close;
View
False

Q7. True or False: Results can be written to multiple ODS destinations.

ods powerpoint file="c:/output/EmpCounts.pptx";
ods excel file="c:/output/EmpCounts.xlsx";
proc freq data=eg1.employee_master;
tables Country*Department;
run;
proc means data=eg1.employee_master;
var Salary;
class Country City;
View
True

Q8. Which option in an ODS statement changes the appearance of the output, including colors, fonts, and borders?

View
STYLE=

Q9. Which statement contains valid syntax for specifying a worksheet name?

View
ods excel sheet_name=’Sales’;

Q10. Suppose that you are creating an Excel file and a PDF file that include results from multiple SAS procedures. What determines the text of each worksheet name in the Excel file and the table of contents link in the PDF file?

View
assigned titles

Quiz 13: Programming Question 2.10

Q1. If necessary, start SAS Studio. Open p106q2.sas from the programs folder. Modify the program to do the following:

Create a PDF file named truck.pdf in the output folder that combines the results of the two procedures without a page break between the reports.

Apply the Journal style.

In the navigation pane, find the truck.pdf file in the output folder. Right-click the file and select Download File. What is the label for the first bookmark in the PDF table of contents?

View
The Freq Procedure

Q2. Do both reports fit on a single page?

View
yes

Week 3 Quiz Answers

Quiz 1: Controlling DATA Step Processing Review Questions

Q1. Which of the following is not created during the compilation phase?

View
the first observation

Q2. During the compilation phase, SAS scans each statement in the DATA step, looking for syntax errors. Which of the following is not considered a syntax error?

View
incorrect data values

Q3. nUnless otherwise directed, how many times does the DATA step loop execute?

View
once for each row in the input file

Q4. At the beginning of the execution phase, the value of N is 1, the value of ERROR is 0, and the values of the remaining variables are set to which of the following?

View
missing

Q5. Suppose you run a program that causes three data errors. What is the value of the automatic variable ERROR when the row that contains the third error is processed?

View
2

Q6. Which of the following actions occurs at the beginning of an iteration of the DATA step?

View
The values of variables created in programming statements are reset to missing in the program data vector.

Q7. Consider the following DATA step. Based on the sample input file below, in what order are the variables stored in the new fin2 table?

data fin2;
set finance;
keep Name Raise NewSalary Date;
if Salary>25000 then Raise=0.03;
else Raise=0.05;
NewSalary=(Salary*Raise)+Salary;
run;
View
Name, Raise, NewSalary, Date

Q8. If the input table contains five columns, which PUTLOG statements create the following results in the SAS log?

View
putlog “NOTE: Begin DATA Step”;
putlog all;

Q9. After this program runs, how many rows are in the forecast table, assuming that there are 10 rows in the sales table?

data forecast;
set sales;
Qtr=1;
Sales=Sales1.01; output; Qtr=2; Sales=Sales1.01;
output;
Qtr=3;
Sales=Sales*1.01;
View
30

Q10. Suppose there are 1,000 total customers, and 200 of those customers have Gold status. After this code runs, how many rows are in the gold table and how many rows are in the other table?

data gold other;
set customers;
if Status="Gold" then output gold;
run;
View
200 in gold and 800 in other

Q11. After this code runs, how many columns are in the Canada table if there are 10 columns in the input customer table?

data Canada(drop=State Zip) US(drop=Province);
set customer(keep=ID Name Country Status
Sales State Zip Province);
if Country=”Canada” then output Canada;
else if Country=”US” then output us;
drop Country;
run;

View
5
Get All Course Quiz Answers of Business English Specialization

Business English: Management and Leadership Quiz Answers

Business English: Finance and Economics Quiz Answers

Business English: Marketing and Sales Quiz Answers

Team Networking Funda
Team Networking Funda

We are Team Networking Funda, a group of passionate authors and networking enthusiasts committed to sharing our expertise and experiences in networking and team building. With backgrounds in Data Science, Information Technology, Health, and Business Marketing, we bring diverse perspectives and insights to help you navigate the challenges and opportunities of professional networking and teamwork.

Leave a Reply

Your email address will not be published. Required fields are marked *