Introduction
Welcome to Edition 20 of Making SAS Accessible to Everyone. This final quiz installment tests your knowledge of concepts from Editions 14 to 17, including:
Combining tables
Processing repetitive code
Restructuring data tables
Introduction to the SAS Macro Language
This edition features 20 questions, a mix of multiple choice and true/false, to strengthen your confidence in these intermediate SAS topics.
1. Multiple Choice Questions
Q1. Which statement in SAS is used to combine tables vertically?
A. SET
B. MERGE
C. APPEND
D. JOIN
Q2. Which option is used with PROC APPEND to suppress error if the dataset doesn’t exist?
A. SKIPIFMISSING
B. NODATA
C. FORCE
D. NOPROMPT
Q3. Which statement performs a one-to-one merge in a DATA step?
A. SET A B
B. MERGE A B
C. JOIN A B
D. UPDATE A B
Q4. What does the DO UNTIL loop do?
A. Executes only if the condition is true from the start
B. Executes at least once and continues until condition is true
C. Skips execution if false
D. Only works in PROC SQL
Q5. Which loop allows fixed iteration based on a counter?
A. DO WHILE
B. REPEAT
C. DO UNTIL
D. DO index=start TO end
Q6. Which function transposes columns into rows?
A. COMPRESS
B. TRANSPOSE
C. TRANSFER
D. RESTRUCTURE
Q7. Which procedure is used to reshape wide data into long format?
A. PROC RESHAPE
B. PROC FORMAT
C. PROC TRANSPOSE
D. PROC STRUCTURE
Q8. What macro statement is used to define a macro?
A. %MACRO
B. %DEFINE
C. %PROC
D. %LET
Q9. Which macro variable contains the current SAS date?
A. &TODAY
B. &SYSDATE
C. &SYSDATE9
D. &DATE
Q10. Which function is used in a DATA step to create a macro variable?
A. SYMPUT
B. MACROGEN
C. CALL SYMPUT
D. SETMACRO
2. True or False Questions
Q11. MERGE requires sorted datasets by the BY variable.
True / False
Q12. PROC APPEND creates a new dataset if the base does not exist.
True / False
Q13. UPDATE modifies the master table with values from a transaction table.
True / False
Q14. The DO WHILE loop always executes at least once.
True / False
Q15. The RETAIN statement can be used to carry values across loop iterations.
True / False
Q16. PROC TRANSPOSE converts rows into columns and vice versa.
True / False
Q17. %LET is used to assign values to macro variables.
True / False
Q18. The %MEND statement ends the definition of a SAS macro.
True / False
Q19. You can use macro variables inside titles and labels.
True / False
Q20. Macro variables defined with %LET can be used across multiple DATA steps.
True / False
Answers & Explanations
Q1. A. SET – Combines tables by stacking them row-wise.
Q2. C. FORCE – Allows appending even when structures differ.
Q3. B. MERGE A B – Combines rows with matching BY values.
Q4. B. Executes at least once and continues until condition is true – Ensures the loop runs at least once.
Q5. D. DO index=start TO end – A simple counter-based loop.
Q6. B. TRANSPOSE – Used to pivot data.
Q7. C. PROC TRANSPOSE – Reshapes data from wide to long format or vice versa.
Q8. A. %MACRO – Declares a macro.
Q9. C. &SYSDATE9 – Provides the current date.
Q10. C. CALL SYMPUT – Passes values from a DATA step into macro variables.
Q11. True – Datasets must be sorted before a MERGE by a BY variable.
Q12. False – It will fail unless the BASE exists, unless FORCE is used.
Q13. True – UPDATE applies changes from transaction datasets.
Q14. False – It runs only if the condition is true at entry.
Q15. True – RETAIN maintains variable values across iterations.
Q16. True – That’s the main use of TRANSPOSE.
Q17. True – %LET is the standard way to define macros.
Q18. True – %MEND ends a macro definition.
Q19. True – Titles and labels can resolve macro variables.
Q20. True – Global macro variables persist through steps.
This concludes the Making SAS Accessible to Everyone series. In upcoming series, we will delve into specific programming tools such as macro design patterns, advanced features of key SAS procedures, applied statistical methods, and the use of SAS Enterprise Guide.
Keep going strong with 3 D Statistical Learning!
We would like to thank Dr. Dany Djeudeu once again for his expert contributions to this educational series.
We help businesses and researchers solve complex challenges by providing expert guidance in statistics, machine learning, and tailored education.
Our core services include:
– Statistical Consulting:
Comprehensive consulting tailored to your data-driven needs.
– Training and Coaching:
In-depth instruction in statistics, machine learning, and the use of statistical software such as SAS, R, and Python.
– Reproducible Data Analysis Pipelines:
Development of documented, reproducible workflows using SAS macros and customized R and Python code.
– Interactive Data Visualization and Web Applications:
Creation of dynamic visualizations and web apps with R (Shiny, Plotly), Python (Streamlit, Dash by Plotly), and SAS (SAS Viya, SAS Web Report Studio).
– Automated Reporting and Presentation:
Generation of automated reports and presentations using Markdown and Quarto.
– Scientific Data Analysis:
Advanced analytical support for scientific research projects.