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?
- log
- output data
- results
- all of the above
Q2. Which of the following is a SAS syntax requirement?
- Separate each step with a line space.
- Begin each statement in column one.
- Put only one statement on each line.
- 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";
- one
- two
- three
- four
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";
- 10
- 2
- 1
- 6
- 4
Q5. Which of the following statements are considered step boundaries (the end of one step and the beginning of another)?
- RUN, QUIT, DATA, and PROC
- RUN, EXIT, and END
- RUN, END, DATA, and PROC
- RUN, QUIT, and END
Q6. What generally happens when SAS detects a syntax error?
- SAS stops processing the entire program.
- SAS continues to process the step, and the SAS log displays messages about the error.
- SAS stops processing the step in which the error occurred, and the SAS log displays messages about the error.
- SAS stops processing the step in which the error occurred, and the results tab 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;
- Yes. Every comment line must end with a semicolon.
- No. The comment is correctly specified.
- Yes. The comment is on more than one line.
- Yes. There is a semicolon in the middle of the comment.
Q8. Based on the following program and data, which of the following is true.
proc print data=cities;
where STATE='ca';
run;
- A syntax error is generated because STATE is uppercase in the program.
- A syntax error is generated because single quotation marks are used in the WHERE statement.
- There are no syntax errors, and three rows are printed.
- There are no syntax errors, but no rows are printed.
Quiz 3: Accessing Data Review Questions
Q1. SAS tables consist of which of the following components?
- info portion and DATA step
- descriptor portion and data portion
- descriptor portion and value portion
- PROC step and DATA step
Q2. What type of variable is Salary in the table below?
- either character or numeric
- numeric
- character
- cannot tell from the data shown
Q3. With the system option VALIDVARNAME=V7, which of the following variable names is valid?
- 4BirthDate
- $Cost
- Items
- Tax-Rate
- all of the above
Q4. Which of the following files is a permanent SAS file?
- Work.PrdSale
- MySales
- Certxl.Quarter1
- all of the above
Q5. What is the default length for the SAS date column BillDate?
- 8
- unknown
- 9
- 10
Q6. Which LIBNAME statement defines the state library to read SAS files in the myfiles\popstats folder on the C: drive?
- libname states ‘c:\myfiles\’;
- libname base states ‘c:\myfiles\popstats’;
- libname states sas ‘c:\myfiles\popstats’;
- libname states ‘c:\myfiles\popstats’;
Q7. Which data source could be read using a library?
- 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?
- the name of a folder or directory where files are stored
- credentials to access protected files
- instructions for creating temporary SAS files
- 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;
- TAB
- DBMS=TAB
- DLM=TAB
- DLM=” “
Q10. Which statement about the CONTENTS procedure is false?
- PROC CONTENTS can be used to list all tables in a library.
- The PROC CONTENTS report includes the engine used to read the data.
- PROC CONTENTS lists a sample of the first five rows from the data.
- 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?
- proc contents data=orion;
- proc contents data=orion.all;
- proc contents data=orion.all nods;
- 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?
- character
- numeric
Quiz 7: Exploring Data Review Questions
Q1. What does a PROC PRINT report display by default?
- PROC PRINT displays all rows and column in the table. If you want an additional column for row numbers, you can request it.
- 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.
- PROC PRINT does not create a default report. You must specify the rows and columns to be displayed.
- PROC PRINT displays columns in the following order: a column for row numbers, all character columns, and all numeric columns.
Q2. Which procedure produces a report that lists the number of rows for each distinct value in a selected column?
- CONTENTS
- MEANS
- FREQ
Q3. Which FORMAT statement produces the following results?
- format Order_Date ddmmyyyy. Cost_Price Retail_Price dollar10.2;
- format Order_Date ddmmyy10. Cost_Price Retail_Price dollar10.2;
- format Order_Date date10. Cost_Price Retail_Price $10.2;
- format Order_Date dmy10. Cost_Price Retail_Price dollar10.2;
Q4. Which statement in PROC MEANS specifies the numeric columns to summarize?
- COL
- TABLES
- VAR
- MEANS
Q5. Which statement selects rows with BirthDate on or after January 1, 1980?
- where BirthDate ge 1/1/1980;
- where BirthDate ge “01JAN1980″d;
- where BirthDate >= ‘1/1/1980’d;
- where Birthdate >= “01JAN1980”;
Q6. Which statement selects ProductID values with CX as the second and third letters in the string?
- where ProductID like “%CX%”;
- where ProductID like “CX“;
- where ProductID like “_CX%”;
- where ProductID like “_CX*”;
Q7. Which statement selects rows where Country is either Argentina or Brazil?
- where Country=”Argentina” or Country=”Brazil”;
- where Country in(“Argentina”, “Brazil”);
- where Country in(“Argentina” “Brazil”);
- all of the above
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;
- True
- False
Q9. Which step creates a new, temporary sorted table named calc?
proc sort data=work.calc out=finance.dividend;
run;
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;
- zero
- one
- three
- four
Quiz 8: Programming Question 1.06
Q1. If necessary, start SAS Studio. Open p103q1.sas from the programs folder.
- Identify and fix the syntax errors.
- Run the program.
- What is the name of the first player listed in the baseball_sort table?
- Anderson, Dave
- Harper, Terry
Q2. How many rows are included in the PROC PRINT result?
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?
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.
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?
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.
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?
/* 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.
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 */
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?
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.
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.
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.
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?
- execution
- compilation
Q2. Which statement about the following program is true?
data australia;
set orion.sales;
where Country='AU';
run;
- The program reads a temporary table and creates a permanent table.
- The program does not execute because of syntax errors.
- 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?
- AvgQ=mean(Q1, Q2, Q3, Q4);
- 3
- 4
- . (missing value)
- The statement generates a syntax error.
Q4. Which expression extracts the first five positions from PostalCode?
- PostalCode5=substr(PostalCode, 5);
- PostalCode5=substr(PostalCode, 1, ‘-‘);
- PostalCode5=substr(PostalCode,1-5);
- 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;
- Age is calculated as a precise number of years (including decimal values).
- Age is calculated and rounded to the nearest whole number.
- Age is not calculated because the DROP statement is before the assignment statement.
- Age is not calculated because the TODAY function does not include any arguments.
Q6. Which of the following is a way that the length of a new variable could be set in the DATA step?
- by the length of the variable the first time it is referenced in the DATA step
- in an assignment statement
- using a LENGTH statement
- all of the above
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;
- 5
- 8
- 10
- It depends on the first value of Type in the cert.records table.
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;
- West
- East
- Other
- Missing
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;
- West
- East
- Other
- missing
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;
- True
- False
Quiz 2: Programming Question 2.01
Q1. If necessary, start SAS Studio. Open and examine the sashelp.holiday table.
- Open p104q1.sas from the programs folder.
- Identify and fix the syntax errors. The values of CountryCode should be the last two letters of Category. The output table should include the Desc, CountryCode, and Date columns.
- Run the program.
- How many holidays where CountryCode is CA are included in the output table? Note: Type a number for your answer.
- Enter answer here
Q2. What value should be provided as the second argument of the SUBSTR function to correctly create the CountryCode column?
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?
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:
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?
Answer: 16
Q2. What is the total number of middle-level sales reps?
Answer: 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?
Answer: 15
Q2. How many years has the employee in row number 1 of the sorted bonus table been employed?
Answer: 29 Year
Q3. How many employees have 20 vacation days?
Answer: 7 employees
Q4. What is the bonus amount for the second employee listed in the sorted bonus table?
Answer: $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;
- ABC Company
- Inventory Report
- Inventory Report
- ABC Company
- Sales Report
- 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;
- The label for BP_Status appears in the FREQ report.
- The label for BP_Status appears in the PRINT report.
- The label for BP_Status appears in both reports.
- The column BP_Status has a permanent label in the data.health table.
Q3. Which of the following statements about the BY statement in a reporting procedure is false?
- First./Last. variables are created for each BY variable.
- The BY statement can be used in the PRINT, MEANS, FREQ, and UNIVARIATE procedures.
- The procedure results are grouped by the unique values of the BY variables.
- The input data must be sorted by the BY variables.
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;
- id Employee_ID;
- sum Salary;
- keep Employee_ID Job_Title Salary;
- a and b
- b and c
Q5. By default, PROC FREQ creates a table of frequencies and percentages for which column types?
- character columns
- numeric columns
- both character and numeric columns
- None. Columns must always be specified.
Q6. Which TABLES statement can be used to create the following output?
- tables Department*City;
- tables Department*City / norow nocol;
- tables Department City / crosslist;
- tables Department City/freq percent;
Q7. Which option is not required in the PROC FREQ step to produce this output?
- LIST
- NLEVELS
- NOCUM
- ORDER=FREQ
Q8. Which statement about the MEANS procedure is true?
- The input table must be sorted by the column(s) in the CLASS statement.
- Default statistics include N, SUM, MEAN, MIN, and MAX.
- The default output is a table.
- 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;
- ways all;
- ways 1, 2, 3;
- ways 0 1;
- ways 2;
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;
- True
- 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?
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?
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?
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?
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
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?
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?
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.
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.
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?
- The INFILE= option identifies the input SAS table.
- The OUTFILE= option specifies the path and file name of the external data file being created.
- The DBMS= option specifies the database identifier for the type of file being created.
- The REPLACE option specifies to overwrite an existing file.
Q2. Which PROC EXPORT step contains valid syntax?
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';
- True
- 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;
- two SAS tables: hr.US_Emp and hr.AU_Emp
- two Excel workbooks: hr.US_Emp and hr. AU_Emp
- two worksheets in the Excel workbook employee: US_Emp and AU_Emp
- two worksheets in the Excel workbook employee_master: US_Emp and AU_Emp
Q5. Which of the following is not a valid output format when using the Output Delivery System (ODS)?
- CSVALL
- EXCEL
- POWERPOINT
- WORD
- HTML
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;
- True
- 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;
- True
- False
Q8. Which option in an ODS statement changes the appearance of the output, including colors, fonts, and borders?
- STYLE=
- OPTIONS=
- LAYOUT=
- CSS=
Q9. Which statement contains valid syntax for specifying a worksheet name?
- ods proctitle sheet_name=’Sales’;
- ods excel sheet_name=’Sales’;
- ods proctitle options(sheet_name=’Sales’);
- ods excel options(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?
- assigned titles
- procedure names
- Sheet1, Sheet2, and so on
- Output1, Output2, and so on
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?
- PROC FREQ Table
- The Freq Procedure
- PROC FREQ Output
Q2. Do both reports fit on a single page?
- yes
- no
Week 3 Quiz Answers
Quiz 1: Controlling DATA Step Processing Review Questions
Q1. Which of the following is not created during the compilation phase?
- the data set descriptor portion
- the program data vector
- the N and ERROR automatic variables
- 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?
- incorrect data values
- missing or invalid punctuation
- invalid options or formats
- missing or misspelled keywords
Q3. nUnless otherwise directed, how many times does the DATA step loop execute?
- once for each DATA step statement
- once for each row in the input file
- once for each column in the input file
- once for each compilation phase
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?
- 0
- 1
- undefined
- 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?
- 0
- 1
- 2
- 3
Q6. Which of the following actions occurs at the beginning of an iteration of the DATA step?
- The automatic variables N and ERROR are incremented by 1.
- The DATA step stops execution.
- The descriptor portion of the data set is written.
- 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;
- Name, Raise, NewSalary, Date
- SSN, Name, Salary, Date, Raise, NewSalary
- Name, Date, Raise, NewSalary
- Salary, NewSalary, Name, Raise
Q8. If the input table contains five columns, which PUTLOG statements create the following results in the SAS log?
putlog "NOTE: Begin DATA Step";
putlog Name Sex Age Height Weight ERROR N;
putlog NOTE="Begin DATA Step";
putlog all;
putlog "NOTE: Begin DATA Step";
putlog all;
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;
- 10
- 30
- 40
- unknown
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;
- 200 in gold and 800 in other
- 200 in gold and 0 in other
- 1000 in gold and 0 in other
- 1000 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;
- 5
- 6
- 7
- 10
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