SAS Advanced Programmer Practice Exam Verified
Questions, Correct Answers, and Detailed Explanations for
Computer Science Students||Already Graded A+
1. Which of the following statements is true about the BY statement in SAS?
A. It is required in a PROC SORT step
B. It automatically sorts the dataset
C. It assumes the dataset is already sorted
D. It can be used without any prior procedures
The BY statement requires that the data be sorted prior, unless used with PROC
SQL or PROC MEANS with CLASS.
2. What is the purpose of the FIRST. and LAST. variables in a BY-group
processing?
A. To indicate missing values
B. To identify the first and last observation in each BY group
C. To create permanent variables
D. To automatically sort data
FIRST.variable and LAST.variable are temporary variables created during BY-
group processing to flag the first and last observations within each group.
3. Which function would you use to remove leading and trailing spaces in a
character variable?
A. LEFT
B. RIGHT
C. STRIP
D. TRIM
The STRIP function removes both leading and trailing spaces; TRIM only
removes trailing spaces.
4. What does the RETAIN statement do in a DATA step?
A. Deletes variables after execution
B. Holds the value of a variable across iterations of the DATA step
,C. Sorts the dataset
D. Creates temporary arrays
The RETAIN statement prevents SAS from setting a variable to missing at the
start of each iteration.
5. How does PROC SQL differ from DATA step merges?
A. PROC SQL cannot join tables
B. PROC SQL can join tables without prior sorting
C. DATA step cannot combine datasets
D. PROC SQL only works with one dataset at a time
PROC SQL performs joins without requiring the datasets to be sorted, unlike the
DATA step merge.
6. Which function returns the position of a substring within a string?
A. FINDC
B. SUBSTR
C. INDEX
D. SCAN
INDEX(string, substring) returns the starting position of substring in string.
7. When using arrays in SAS, what is required?
A. Arrays must be permanent
B. Arrays must reference existing variables or create temporary variables
C. Arrays can only have numeric variables
D. Arrays automatically sort variables
Arrays in SAS are a way to reference multiple variables; they can point to
existing variables or create temporary ones.
8. How do you create a SAS macro variable from a DATA step?
A. %LET
B. CALL SYMPUTX
C. %DO
, D. %IF
CALL SYMPUTX assigns a value to a macro variable during DATA step execution.
9. What is the difference between PUT and INPUT functions?
A. Both convert numeric to character
B. PUT converts numeric to character, INPUT converts character to numeric
C. Both are used to read external files
D. PUT is for printing only
PUT formats numeric or character values as strings; INPUT converts character
strings to numeric or uses informat.
10. Which SAS procedure can produce summary statistics for multiple
variables by groups?
A. PROC PRINT
B. PROC REPORT
C. PROC MEANS
D. PROC FORMAT
PROC MEANS calculates statistics like mean, sum, min, max for numeric
variables, optionally by BY groups.
11. How do you suppress the output of a SAS procedure?
A. NOPRINT option
B. NOOUTPUT
C. Use NOPRINT in the PROC statement
D. Disable the log
Many procedures (like PROC MEANS, PROC FREQ) support NOPRINT to execute
without generating output.
12. Which SAS option can control the length of variable names in output
datasets?
A. VARLEN
B. MAXNAME
Questions, Correct Answers, and Detailed Explanations for
Computer Science Students||Already Graded A+
1. Which of the following statements is true about the BY statement in SAS?
A. It is required in a PROC SORT step
B. It automatically sorts the dataset
C. It assumes the dataset is already sorted
D. It can be used without any prior procedures
The BY statement requires that the data be sorted prior, unless used with PROC
SQL or PROC MEANS with CLASS.
2. What is the purpose of the FIRST. and LAST. variables in a BY-group
processing?
A. To indicate missing values
B. To identify the first and last observation in each BY group
C. To create permanent variables
D. To automatically sort data
FIRST.variable and LAST.variable are temporary variables created during BY-
group processing to flag the first and last observations within each group.
3. Which function would you use to remove leading and trailing spaces in a
character variable?
A. LEFT
B. RIGHT
C. STRIP
D. TRIM
The STRIP function removes both leading and trailing spaces; TRIM only
removes trailing spaces.
4. What does the RETAIN statement do in a DATA step?
A. Deletes variables after execution
B. Holds the value of a variable across iterations of the DATA step
,C. Sorts the dataset
D. Creates temporary arrays
The RETAIN statement prevents SAS from setting a variable to missing at the
start of each iteration.
5. How does PROC SQL differ from DATA step merges?
A. PROC SQL cannot join tables
B. PROC SQL can join tables without prior sorting
C. DATA step cannot combine datasets
D. PROC SQL only works with one dataset at a time
PROC SQL performs joins without requiring the datasets to be sorted, unlike the
DATA step merge.
6. Which function returns the position of a substring within a string?
A. FINDC
B. SUBSTR
C. INDEX
D. SCAN
INDEX(string, substring) returns the starting position of substring in string.
7. When using arrays in SAS, what is required?
A. Arrays must be permanent
B. Arrays must reference existing variables or create temporary variables
C. Arrays can only have numeric variables
D. Arrays automatically sort variables
Arrays in SAS are a way to reference multiple variables; they can point to
existing variables or create temporary ones.
8. How do you create a SAS macro variable from a DATA step?
A. %LET
B. CALL SYMPUTX
C. %DO
, D. %IF
CALL SYMPUTX assigns a value to a macro variable during DATA step execution.
9. What is the difference between PUT and INPUT functions?
A. Both convert numeric to character
B. PUT converts numeric to character, INPUT converts character to numeric
C. Both are used to read external files
D. PUT is for printing only
PUT formats numeric or character values as strings; INPUT converts character
strings to numeric or uses informat.
10. Which SAS procedure can produce summary statistics for multiple
variables by groups?
A. PROC PRINT
B. PROC REPORT
C. PROC MEANS
D. PROC FORMAT
PROC MEANS calculates statistics like mean, sum, min, max for numeric
variables, optionally by BY groups.
11. How do you suppress the output of a SAS procedure?
A. NOPRINT option
B. NOOUTPUT
C. Use NOPRINT in the PROC statement
D. Disable the log
Many procedures (like PROC MEANS, PROC FREQ) support NOPRINT to execute
without generating output.
12. Which SAS option can control the length of variable names in output
datasets?
A. VARLEN
B. MAXNAME