Base SAS Global Certification (A00-231) Practice Test
  • 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

  1. 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 = . ;

  2. 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;

  3. What does the following SAS code do?

     data work.sales; set company.sales; run; 

    a) Creates a new dataset work.sales by modifying company.sales.
    b) Deletes all observations from company.sales.
    c) Creates a copy of company.sales in the work library.
    d) Merges company.sales with another dataset.

    Answer: c) Creates a copy of company.sales in the work library.


Section 2: Data Manipulation

  1. 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.

  2. Which statement correctly creates a new variable total_sales by summing q1, q2, q3, and q4?
    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 b

    Answer: d) Both a and b


Section 3: Data Step and Procedures

  1. 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

  2. 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

  1. 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;

  2. 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

  1. 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

  1. 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;

  2. What does the following SAS log message indicate?

    
     

    ERROR: Variable Salary not found.

    a) The variable Salary is not in the dataset.
    b) The variable Salary has missing values.
    c) The variable Salary is formatted incorrectly.
    d) The variable Salary is a numeric variable.

    Answer: a) The variable Salary is not in the dataset.

  3. Which SAS option enables detailed macro execution debugging?
    a) OPTIONS MPRINT;
    b) OPTIONS SYMBOLGEN;
    c) OPTIONS MLOGIC;
    d) OPTIONS DEBUG;

    Answer: c) OPTIONS MLOGIC;

  4. 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.

  5. 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=

  6. 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_;

  7. 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.

  8. Which SAS function returns the current system error message?
    a) SYSERRMSG()
    b) ERRORMSG()
    c) ERRORTEXT()
    d) SYSERROR()

    Answer: a) SYSERRMSG()

  9. 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 first 0 records are deleted.

    Answer: a) No records are processed in any dataset.

  10. 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

  1. 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)

  2. Which function removes both leading and trailing spaces from a character string?
    a) COMPRESS()
    b) STRIP()
    c) TRIM()
    d) LEFT()

    Answer: b) STRIP()

  3. 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)

  4. 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()

  5. 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()

  6. Which SAS function returns the current system date in a numeric format?
    a) TODAY()
    b) SYSDATE()
    c) DATE()
    d) CURRENTDATE()

    Answer: a) TODAY()

  7. Which function is used to convert a numeric value into a character string?
    a) PUT()
    b) INPUT()
    c) FORMAT()
    d) CHAR()

    Answer: a) PUT()

  8. 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()

  9. 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) Rounds original_var to the nearest 0.1
    c) Converts original_var to a character variable
    d) Truncates original_var

    Answer: b) Rounds original_var to the nearest 0.1

  10. 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

  1. Which statement is used to combine multiple SAS datasets by stacking them together?
    a) MERGE
    b) JOIN
    c) SET
    d) APPEND

    Answer: c) SET

  2. 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 values

    Answer: b) To merge datasets by a common variable

  3. 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 of old
    c) The last 10 observations of old
    d) The entire dataset old

    Answer: b) Observations 5 through 10 of old

  4. 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

  5. Which function is used to concatenate two character variables in SAS?
    a) CATX()
    b) JOIN()
    c) CONCAT()
    d) APPEND()

    Answer: a) CATX()

  6. 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 numeric

    Answer: a) Retains the last value of a variable for the next iteration

  7. 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

  8. 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 message

    Answer: c) The new dataset overwrites the existing one

  9. 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

  10. 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

  1. 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=

  2. Which SAS statement writes data to an external file?
    a) WRITE
    b) FILE
    c) EXPORT
    d) PROC EXPORT

    Answer: b) FILE

  3. 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 dataset

    Answer: a) To print output to the SAS log or an external file

  4. 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

  5. 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

  6. 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;

  7. 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

  8. 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 error

    Answer: a) Stops processing after reading 10 observations

  9. 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_

  10. 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

  1. 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

  2. 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

  3. 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 error

    Answer: b) Displays a window to debug execution

  4. 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 execution

    Answer: c) SAS will generate an error in the log

  5. Which SAS option is used to suppress warning messages in the log?
    a) NOWARN
    b) NONOTES
    c) SUPPRESSWARNINGS
    d) NOSTIMER

    Answer: a) NOWARN

  6. 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 encountered

    Answer: a) Writes custom messages to the SAS log

  7. 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

  8. 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 automatically

    Answer: a) Aborts the session immediately when an error occurs

  9. 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";

  10. 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;