Get All Weeks Preparing for the SAS Programming Certification Exam Quiz Answers
Table of Contents
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?
Q2. Which of the following is a SAS syntax requirement?
View.
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";
ViewQ4. 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";
ViewQ5. Which of the following statements are considered step boundaries (the end of one step and the beginning of another)?
ViewQ6. What generally happens when SAS detects a syntax error?
ViewQ7. Does this comment contain syntax errors?
Report created for budget
presentation; revised October 15.
****;
proc print data=sales;
run;
ViewQ8. Based on the following program and data, which of the following is true.
proc print data=cities;
where STATE='ca';
run;
ViewQuiz 3: Accessing Data Review Questions
Q1. SAS tables consist of which of the following components?
ViewQ2. What type of variable is Salary in the table below?
ViewQ3. With the system option VALIDVARNAME=V7, which of the following variable names is valid?
ViewQ4. Which of the following files is a permanent SAS file?
ViewQ5. What is the default length for the SAS date column BillDate?
ViewQ6. Which LIBNAME statement defines the state library to read SAS files in the myfiles\popstats folder on the C: drive?
ViewQ7. Which data source could be read using a library?
Viewtab-delimited file
comma-delimited file
all of the above
Q8. When you specify an engine for a library, what are you specifying?
ViewQ9. 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;
ViewQ10. Which statement about the CONTENTS procedure is false?
ViewQ11. 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?
ViewQuiz 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?
ViewQuiz 7: Exploring Data Review Questions
Q1. What does a PROC PRINT report display by default?
ViewQ2. Which procedure produces a report that lists the number of rows for each distinct value in a selected column?
ViewQ3. Which FORMAT statement produces the following results?
ViewQ4. Which statement in PROC MEANS specifies the numeric columns to summarize?
ViewQ5. Which statement selects rows with BirthDate on or after January 1, 1980?
ViewQ6. Which statement selects ProductID values with CX as the second and third letters in the string?
ViewQ7. Which statement selects rows where Country is either Argentina or Brazil?
ViewQ8. 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;
ViewQ9. Which step creates a new, temporary sorted table named calc?
proc sort data=work.calc out=finance.dividend;
run;
Viewby 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 --> Viewthree<!-- /wp:shortcode -->
Quiz 8: Programming Question 1.06
Q1. If necessary, start SAS Studio. Open p103q1.sas from the programs folder.
ViewQ2. How many rows are included in the PROC PRINT result?
ViewQ3. Which value of Position has the most players?
ViewQ4. What is the average value of the Salary column? Note: Type your answer exactly as the value is displayed.
ViewIf 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?
Viewtables EmpID / nocum;
run;
Q2. How many rows in the Country column violate the data rules? Note: Type a number for your answer.
Viewset 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?
Viewproc 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.
Viewset 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.
ViewThe 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.
ViewQ4. 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.
ViewWeeks 2 Quiz Answers
Quiz 1: Preparing Data Review Questions
Q1. In which phase does the DATA step read rows from the input table?
ViewQ2. Which statement about the following program is true?
data australia;
set orion.sales;
where Country='AU';
run;
View
Q3. Given the assignment statement below, what is the value of AvgQ for the row that is shown?
ViewQ4. Which expression extracts the first five positions from PostalCode?
ViewQ5. Which statement about the following program is true?
data customer_age;
set orion.customers;
drop BirthDate;
Age=yrdif(BirthDate, today(),"AGE");
run;
ViewQ6. Which of the following is a way that the length of a new variable could be set in the DATA step?
ViewQ7. 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;
ViewQ8. 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;
ViewQ9. 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;
ViewQ10. 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;
ViewQuiz 2: Programming Question 2.01
Q1. If necessary, start SAS Studio. Open and examine the sashelp.holiday table.
ViewQ2. What value should be provided as the second argument of the SUBSTR function to correctly create the CountryCode column?
ViewQ3. What is the SAS date value for Boxing Day?
ViewQuiz 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:
JobTitle | SalesLevel |
---|---|
Sales Rep. I | Entry |
Sales Rep. II or Sales Rep. III | Middle |
Sales Rep. IV | Senior |
Generate a report that includes the number of Sales employees in each level.
What is the total number of Sales employees?
ViewQ2. What is the total number of middle-level sales reps?
ViewQuiz 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?
Q2. How many years has the employee in row number 1 of the sorted bonus table been employed?
ViewQ3. How many employees have 20 vacation days?
ViewQ4. What is the bonus amount for the second employee listed in the sorted bonus table?
ViewQuiz 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;
ViewInventory 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;
ViewQ3. Which of the following statements about the BY statement in a reporting procedure is false?
ViewQ4. 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;
ViewQ5. By default, PROC FREQ creates a table of frequencies and percentages for which column types?
ViewQ6. Which TABLES statement can be used to create the following output?
ViewQ7. Which option is not required in the PROC FREQ step to produce this output?
ViewQ8. Which statement about the MEANS procedure is true?
ViewQ9. Which WAYS statement creates the following report?
proc means data=employee;
var Salary;
class Country City;
run;
ViewQ10. 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;
ViewQuiz 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?
Viewvar Player Team nHome;
label Player = ‘Player Name’
Team = ‘Team’
nHome = ‘Home Runs’;
run;
Q3. How many total home runs did Baltimore have?
Viewselect 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?
Viewvar 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?
Viewselect 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
Viewselect (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?
Viewselect 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?
Viewtables 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.
ViewPlease 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.
Viewwhere 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?
ViewQ2. Which PROC EXPORT step contains valid syntax?
Viewdata=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';
ViewQ4. 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;
ViewQ5. Which of the following is not a valid output format when using the Output Delivery System (ODS)?
ViewQ6. 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;
ViewQ7. 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;
ViewQ8. Which option in an ODS statement changes the appearance of the output, including colors, fonts, and borders?
ViewQ9. Which statement contains valid syntax for specifying a worksheet name?
ViewQ10. 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?
ViewQuiz 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?
ViewQ2. Do both reports fit on a single page?
ViewWeek 3 Quiz Answers
Quiz 1: Controlling DATA Step Processing Review Questions
Q1. Which of the following is not created during the compilation phase?
ViewQ2. 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?
ViewQ3. nUnless otherwise directed, how many times does the DATA step loop execute?
ViewQ4. 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?
ViewQ5. 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?
ViewQ6. Which of the following actions occurs at the beginning of an iteration of the DATA step?
ViewQ7. 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;
ViewQ8. If the input table contains five columns, which PUTLOG statements create the following results in the SAS log?
Viewputlog 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;
ViewQ10. 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;
ViewQ11. 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;
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