
- by Handson
- March 25, 2025
Base SAS Global Certification (A00-231) Practice Test
Base SAS Global Certification (A00-231) Practice Test
Section 1: SAS Programming Basics
-
Which statement correctly assigns a missing value to a numeric variable in SAS?
a)var1 = null;
b)var1 = ' ';
c)var1 = . ;
d)var1 = 'missing';
Answer: c)
var1 = . ;
-
Which SAS statement correctly reads an external CSV file into a dataset?
a)data mydata; set 'file.csv'; run;
b)data mydata; infile 'file.csv'; run;
c)proc import datafile='file.csv' out=mydata dbms=csv replace; run;
d)proc copy data='file.csv' out=mydata; run;
Answer: c)
proc import datafile='file.csv' out=mydata dbms=csv replace; run;
-
What does the following SAS code do?
data work.sales; set company.sales; run;
a) Creates a new dataset
work.sales
by modifyingcompany.sales
.
b) Deletes all observations fromcompany.sales
.
c) Creates a copy ofcompany.sales
in thework
library.
d) Mergescompany.sales
with another dataset.Answer: c) Creates a copy of
company.sales
in thework
library.
Section 2: Data Manipulation
-
What does the
IFN
function do in SAS?
a) Performs an IF-THEN-ELSE operation in a single function.
b) Checks for missing values.
c) Converts numeric values to character.
d) Generates a random number.Answer: a) Performs an IF-THEN-ELSE operation in a single function.
-
Which statement correctly creates a new variable
total_sales
by summingq1
,q2
,q3
, andq4
?
a)total_sales = sum(q1, q2, q3, q4);
b)total_sales = q1 + q2 + q3 + q4;
c)total_sales = q1 + q2 + q3 + q4 if not missing(q1, q2, q3, q4);
d) Both a and bAnswer: d) Both a and b
Section 3: Data Step and Procedures
-
Which SAS procedure provides descriptive statistics for numeric variables?
a)PROC REPORT
b)PROC MEANS
c)PROC FREQ
d)PROC PRINT
Answer: b)
PROC MEANS
-
Which statement best describes the function of
PROC SORT
?
a) Sorts a dataset in ascending or descending order.
b) Removes duplicate records from a dataset.
c) Creates summary statistics.
d) Merges two datasets.Answer: a) Sorts a dataset in ascending or descending order.
Section 4: SQL and SAS Macros
-
Which PROC SQL statement correctly selects unique customer IDs from a dataset?
a)SELECT DISTINCT customer_id FROM sales;
b)SELECT UNIQUE customer_id FROM sales;
c)SELECT customer_id DISTINCT FROM sales;
d)SELECT customer_id UNIQUE FROM sales;
Answer: a)
SELECT DISTINCT customer_id FROM sales;
-
What is the correct syntax to define a macro in SAS?
a)%macro macro_name; ... %mend;
b)macro macro_name; ... mend;
c)@macro macro_name; ... @mend;
d)#macro macro_name; ... #mend;
Answer: a)
%macro macro_name; ... %mend;
Section 5: Error Handling and Debugging
-
Which SAS statement is used to display error messages in the log window?
a)PUTLOG
b)DEBUG
c)LOGMSG
d)PRINTLOG
Answer: a)
PUTLOG
Section 6: Error Handling and Debugging
-
Which SAS system option is used to display detailed messages about syntax errors in the log?
a)OPTIONS ERRORS=MAX;
b)OPTIONS ERRORCHECK=STRICT;
c)OPTIONS MSGLEVEL=I;
d)OPTIONS ERRORDETAIL;
Answer: c)
OPTIONS MSGLEVEL=I;
-
What does the following SAS log message indicate?
ERROR: Variable Salary not found.
a) The variable
Salary
is not in the dataset.
b) The variableSalary
has missing values.
c) The variableSalary
is formatted incorrectly.
d) The variableSalary
is a numeric variable.Answer: a) The variable
Salary
is not in the dataset. -
Which SAS option enables detailed macro execution debugging?
a)OPTIONS MPRINT;
b)OPTIONS SYMBOLGEN;
c)OPTIONS MLOGIC;
d)OPTIONS DEBUG;
Answer: c)
OPTIONS MLOGIC;
-
Which of the following statements is true regarding SAS error handling?
a) SAS stops execution immediately when it encounters an error.
b) SAS automatically corrects minor syntax errors.
c) SAS continues execution after an error, but the affected step fails.
d) SAS logs errors but does not display them in the log.Answer: c) SAS continues execution after an error, but the affected step fails.
-
Which SAS option controls the number of error messages displayed before SAS stops executing?
a)ERRORSTOP
b)ERRORLIMIT
c)MAXERRORS
d)ERRORS=
Answer: d)
ERRORS=
-
Which SAS statement can help you display all active macro variable values in the log?
a)%PUT _USER_;
b)%DISPLAY _ALL_;
c)PROC OPTIONS; RUN;
d)SHOW _ALL_;
Answer: a)
%PUT _USER_;
-
What does the
PUTLOG
statement do in a DATA step?
a) Writes a dataset to an external file.
b) Displays variable values in the log.
c) Creates a new log file.
d) Formats numerical data in the output window.Answer: b) Displays variable values in the log.
-
Which SAS function returns the current system error message?
a)SYSERRMSG()
b)ERRORMSG()
c)ERRORTEXT()
d)SYSERROR()
Answer: a)
SYSERRMSG()
-
What is the effect of setting
OPTIONS OBS=0;
in SAS?
a) No records are processed in any dataset.
b) All observations are processed.
c) Only the first observation is processed.
d) The first0
records are deleted.Answer: a) No records are processed in any dataset.
-
Which option in SAS forces execution to stop when an error occurs?
a)OPTIONS ERRORCHECK=STRICT;
b)OPTIONS OBS=0;
c)OPTIONS STOPONERROR;
d)OPTIONS ABORT;
Answer: a)
OPTIONS ERRORCHECK=STRICT;
Section 7: SAS Functions and Data Processing
-
Which function is used to extract the first three characters from a string variable in SAS?
a)SCAN(var, 3)
b)SUBSTR(var, 1, 3)
c)LEFT(var, 3)
d)TRIM(var, 3)
Answer: b)
SUBSTR(var, 1, 3)
-
Which function removes both leading and trailing spaces from a character string?
a)COMPRESS()
b)STRIP()
c)TRIM()
d)LEFT()
Answer: b)
STRIP()
-
What will be the value of
y
in the following SAS code?data test; x = " 123 "; y = input(x, 3.); run;
a)
123
b)123
c).
(missing value)
d)Error
Answer: c)
.
(missing value) -
Which function is used to replace all occurrences of a substring within a string?
a)TRANSLATE()
b)SUBSTR()
c)REPLACE()
d)TRANWRD()
Answer: d)
TRANWRD()
-
Which function is used to find the position of a substring in a string?
a)INDEX()
b)SUBSTR()
c)FIND()
d)SEARCH()
Answer: a)
INDEX()
-
Which SAS function returns the current system date in a numeric format?
a)TODAY()
b)SYSDATE()
c)DATE()
d)CURRENTDATE()
Answer: a)
TODAY()
-
Which function is used to convert a numeric value into a character string?
a)PUT()
b)INPUT()
c)FORMAT()
d)CHAR()
Answer: a)
PUT()
-
Which SAS function is used to count the number of words in a character variable?
a)LENGTH()
b)WORDCOUNT()
c)COUNTW()
d)NUMWORDS()
Answer: c)
COUNTW()
-
What does the following code do?
data new; set old; new_var = round(original_var, 0.1); run;
a) Rounds
original_var
to the nearest integer
b) Roundsoriginal_var
to the nearest 0.1
c) Convertsoriginal_var
to a character variable
d) Truncatesoriginal_var
Answer: b) Rounds
original_var
to the nearest 0.1 -
Which function converts a character date value into a numeric SAS date value?
a)CHAR2DATE()
b)DATEVALUE()
c)INPUT()
d)PUT()
Answer: c)
INPUT()
Section 8: Data Manipulation Techniques
-
Which statement is used to combine multiple SAS datasets by stacking them together?
a)MERGE
b)JOIN
c)SET
d)APPEND
Answer: c)
SET
-
What is the purpose of the
MERGE
statement in SAS?
a) To concatenate datasets
b) To merge datasets by a common variable
c) To delete records from a dataset
d) To summarize dataset valuesAnswer: b) To merge datasets by a common variable
-
What will be the output of the following SAS code?
data new; set old (firstobs=5 obs=10); run;
a) The first 5 observations of
old
b) Observations 5 through 10 ofold
c) The last 10 observations ofold
d) The entire datasetold
Answer: b) Observations 5 through 10 of
old
-
Which SAS statement is used to read data from an external CSV file?
a)DATA INFILE
b)DATA IMPORT
c)PROC IMPORT
d)PROC EXPORT
Answer: c)
PROC IMPORT
-
Which function is used to concatenate two character variables in SAS?
a)CATX()
b)JOIN()
c)CONCAT()
d)APPEND()
Answer: a)
CATX()
-
What does the
RETAIN
statement do in a SAS DATA step?
a) Retains the last value of a variable for the next iteration
b) Removes missing values from a variable
c) Keeps only non-duplicate records
d) Converts a variable from character to numericAnswer: a) Retains the last value of a variable for the next iteration
-
Which statement in SAS is used to remove duplicate records from a dataset?
a)REMOVE DUPLICATES
b)PROC SORT NODUPKEY
c)PROC FILTER DISTINCT
d)DATA REMOVE DUPES
Answer: b)
PROC SORT NODUPKEY
-
What will happen if a SAS dataset is created with the same name as an existing dataset?
a) The existing dataset is deleted automatically
b) SAS renames the new dataset
c) The new dataset overwrites the existing one
d) SAS generates an error messageAnswer: c) The new dataset overwrites the existing one
-
Which SAS statement is used to create a subset of a dataset based on a condition?
a)SELECT
b)IF
c)WHERE
d)FILTER
Answer: c)
WHERE
-
Which of the following statements correctly keeps only numeric variables in a new dataset?
a)KEEP _NUMERIC_;
b)WHERE TYPE=NUM;
c)DROP _CHARACTER_;
d)KEEP VARS NUMERIC;
Answer: a)
KEEP _NUMERIC_;
Section 9: Controlling Input and Output
-
Which statement is used to control the number of observations read from a dataset in a DATA step?
a)OBS=
b)FIRSTOBS=
c)WHERE
d)STOP
Answer: a)
OBS=
-
Which SAS statement writes data to an external file?
a)WRITE
b)FILE
c)EXPORT
d)PROC EXPORT
Answer: b)
FILE
-
What is the purpose of the
PUT
statement in a SAS DATA step?
a) To print output to the SAS log or an external file
b) To assign a format to a variable
c) To convert numeric data to character
d) To store data in a new datasetAnswer: a) To print output to the SAS log or an external file
-
Which statement is used to suppress the printing of observation numbers in PROC PRINT?
a)NOOBS
b)NOPRINT
c)OBS=0
d)HIDEOBS
Answer: a)
NOOBS
-
Which SAS procedure is used to print data to the output window?
a)PROC OUTPUT
b)PROC REPORT
c)PROC PRINT
d)PROC DISPLAY
Answer: c)
PROC PRINT
-
Which statement correctly exports a SAS dataset to a CSV file?
a) PROC EXPORT DATA=mydata OUTFILE='C:output.csv' DBMS=CSV REPLACE; b) DATA EXPORT mydata TO 'C:output.csv' FORMAT CSV; c) PROC EXPORT FILE=mydata 'C:output.csv' FORMAT CSV; d) EXPORT mydata TO 'C:output.csv' USING PROC EXPORT;
Answer: a)
PROC EXPORT DATA=mydata OUTFILE='C:output.csv' DBMS=CSV REPLACE;
-
Which of the following is used to read data from a raw text file in a DATA step?
a)INFILE
b)IMPORT
c)INPUTFILE
d)READ
Answer: a)
INFILE
-
What does the following code do?
data new; set old; if _N_ > 10 then stop; run;
a) Stops processing after reading 10 observations
b) Drops observations where_N_ > 10
c) Keeps only observations where_N_ > 10
d) Returns an errorAnswer: a) Stops processing after reading 10 observations
-
Which statement is used to suppress the output of a DATA step without stopping execution?
a)NOPRINT
b)ODS OFF
c)OUTPUT OFF
d)DATA _NULL_
Answer: d)
DATA _NULL_
-
Which SAS statement is used to format the appearance of output values?
a)FORMAT
b)LABEL
c)STYLE
d)PUT
Answer: a)
FORMAT
Section 10: Debugging and Error Handling
-
Which of the following SAS options displays detailed messages about errors in the log?
a)FULLERROR
b)ERRORDETAILS
c)MSGLEVEL=I
d)DEBUGLOG
Answer: c)
MSGLEVEL=I
-
Which log message indicates that a variable has not been initialized in a DATA step?
a)Variable is missing
b)Uninitialized variable
c)Syntax error in line
d)Missing semicolon
Answer: b)
Uninitialized variable
-
What does the
DEBUG
option do in a DATA step?
a) Prints the program step by step
b) Displays a window to debug execution
c) Highlights syntax errors in red
d) Stops execution at the first errorAnswer: b) Displays a window to debug execution
-
What happens if a semicolon is missing in a SAS statement?
a) SAS will ignore the missing semicolon
b) SAS will automatically insert a semicolon
c) SAS will generate an error in the log
d) SAS will terminate executionAnswer: c) SAS will generate an error in the log
-
Which SAS option is used to suppress warning messages in the log?
a)NOWARN
b)NONOTES
c)SUPPRESSWARNINGS
d)NOSTIMER
Answer: a)
NOWARN
-
What does the
PUTLOG
statement do in SAS?
a) Writes custom messages to the SAS log
b) Redirects log messages to an external file
c) Clears the SAS log
d) Stops execution if an error is encounteredAnswer: a) Writes custom messages to the SAS log
-
Which statement is used to handle missing values in a SAS dataset?
a)IF MISSING(variable) THEN
b)IF NULL(variable) THEN
c)WHERE NOT NULL(variable)
d)DROP MISSING(variable)
Answer: a)
IF MISSING(variable) THEN
-
What does the
ERRORABEND
option do in SAS?
a) Aborts the session immediately when an error occurs
b) Logs error messages but continues execution
c) Suppresses all error messages
d) Restarts the SAS session automaticallyAnswer: a) Aborts the session immediately when an error occurs
-
Which statement correctly checks for an invalid numeric value in a character variable?
a)IF var = . THEN PUT "Invalid";
b)IF INPUT(var, ?? BEST.) = . THEN PUT "Invalid";
c)IF var IS NULL THEN PUT "Invalid";
d)IF MISSING(var) THEN PUT "Invalid";
Answer: b)
IF INPUT(var, ?? BEST.) = . THEN PUT "Invalid";
-
How can you force SAS to display only ERROR messages in the log?
a)OPTIONS ERRORS=ONLY;
b)OPTIONS NONOTES NOSOURCE;
c)OPTIONS ERRORS=0;
d)OPTIONS ERRORLOG;
Answer: b)
OPTIONS NONOTES NOSOURCE;