All SAS exams
Free A00-231 practice test: 30 questions with answers
30 original questions for SAS Certified Specialist: Base Programming Using SAS 9.4, drawn from every topic area. Answer each one to see whether you got it right and why. No sign-up.
- Free questions
- 30
- Full bank
- 112 questions
- Real exam
- 40-45 questions, 135 min
- Passing score
- 725 (scale 200-1000)
All 30 A00-231 questions with answers
The same questions as the test above, grouped by exam topic. Open any question to see the answer and explanation.
Manage Data (8 questions)
Question 1
A customer file contains several rows for the same customer ID, and the duplicate rows differ in their address or phone fields. The team needs exactly one row per customer ID in the output. Which PROC SORT keyword or option, used with BY customer_id, achieves this?
- ANODUP, which removes only rows that are identical in every variable
- BNODUPKEY, which keeps one row for each unique value of the BY variable
- CDESCENDING, which sorts the BY variable from largest to smallest value
- DOUT=, which names the data set that receives the sorted rows
Show answer and explanationHide answer
Correct answer: BNODUPKEY checks only the BY variables, so one row per customer ID is kept even when other fields differ. NODUP compares every variable so rows with different addresses or phones would both remain, DESCENDING changes the sort direction, and OUT= only names the output data set.
Question 2
A DATA step contains the statement total + amount; to build a running total of the amount variable. Which statement about this sum statement is correct?
- AIt can be used only inside a PROC step, and it cannot be placed in a DATA step
- BIt resets total to missing at the start of every observation, so a RETAIN statement is always required
- CIt retains total across observations, starts it at zero, and skips missing values of amount
- DIt works only when the data set is sorted by a BY variable, otherwise SAS stops the step
Show answer and explanationHide answer
Correct answer: CThe sum statement automatically retains its variable across iterations, initializes it to zero, and ignores missing values in the expression. It does not need a BY variable or a RETAIN statement, and it is a DATA step statement.
Question 3
A data set is sorted by department and holds one row per employee with a salary variable. The team needs one output row per department that contains the total salary. Which approach is correct?
- AApply a WHERE statement that keeps only salaries above zero, then print the employee rows with PROC PRINT
- BRun PROC TRANSPOSE with an ID statement for department, which adds the salaries into one row per department
- CUse BY department, reset a salary total at FIRST.department, and write one row at LAST.department
- DDeclare salary with a longer LENGTH statement so that the department totals can hold larger values
Show answer and explanationHide answer
Correct answer: CBY-group processing with FIRST. and LAST. variables lets the step restart the total for each department and write one row when the last employee in that department is reached. A WHERE filter keeps rows rather than summing them, PROC TRANSPOSE reshapes rows without adding them, and LENGTH only controls storage width.
Question 4
A DATA step contains status = 'No'; as its first reference to the variable status, and later contains status = 'Pending'; with no LENGTH statement. What value does status hold after the second assignment?
- APending, because SAS extends a character variable's length when a longer value is assigned
- BPending, because a character variable without a LENGTH statement defaults to a length of 200 characters
- CThe step stops with an error because the second value is longer than the first value in the step
- DPe, because the first assignment fixed status at two characters so the longer value is truncated
Show answer and explanationHide answer
Correct answer: DSAS sets the length of a new character variable from its first appearance in the DATA step, so the two-character value 'No' fixes the length at two. The longer value is truncated to fit, which is why a LENGTH statement placed before the first reference is recommended. The other options describe automatic extension, a 200-character default, or an error that SAS does not raise here.
Question 5
A loop must run its body at least once, even when its stopping condition is already true when the loop starts. Which DO loop form meets this requirement?
- AAn IF-THEN statement that wraps a DO group, because the IF tests the condition after the body runs
- BDO WHILE, because the condition is tested before each pass through the body
- CIterative DO with TO, because the counter is checked before the body runs
- DDO UNTIL, because the condition is tested at the bottom of the loop after the body runs
Show answer and explanationHide answer
Correct answer: DDO UNTIL evaluates its condition at the end of each pass, so the body always runs at least once. DO WHILE tests first and can run zero times, an iterative DO runs according to its counter and can also run zero times, and an IF-THEN statement is not a loop.
Question 6
A data set holds one row per store per quarter, with a Sales value on each row and quarter values Q1 to Q4. The data are sorted by store. The team needs one row per store with columns Q1 to Q4 holding the sales. Which PROC TRANSPOSE statements produce this layout?
- ABY quarter; ID store; VAR sales;
- BID sales; VAR quarter; BY store;
- CVAR store quarter sales;
- DBY store; ID quarter; VAR sales;
Show answer and explanationHide answer
Correct answer: DBY store defines one output row per store, ID quarter names the new columns from the quarter values, and VAR sales supplies the values placed in those columns. The other choices assign the variables the wrong roles, such as using store as the ID or making the grouping variable the source of the values.
Question 7
A program runs %let region = West; and must place the current value into a title. Which TITLE statement displays Sales for West?
- Atitle 'Sales for ®ion';
- Btitle "Sales for ®ions";
- Ctitle "Sales for region";
- Dtitle "Sales for ®ion";
Show answer and explanationHide answer
Correct answer: DMacro variable references resolve inside double quotes but not inside single quotes, so only the double-quoted ®ion version shows West. Leaving out the ampersand prints the word region, and ®ions refers to a different, undefined macro variable.
Question 8
A %LET statement appears outside any macro definition in an open program. Which scope does the resulting macro variable have?
- AGlobal, so later DATA and PROC steps in the same session can reference it
- BLocal to the next DATA step only, and it is deleted when that step ends
- CLocal to the PROC step that immediately follows, and it is removed afterward
- DStored as a data set variable, so it appears as a column in every output table
Show answer and explanationHide answer
Correct answer: AA %LET outside a macro creates a global macro variable that remains available for the rest of the session. A %LET inside a macro definition creates a local variable by default, and %LET never creates a column in a data set.
Access and Create Data Structures (8 questions)
Question 9
A programmer needs an intermediate data set that is used only during the current SAS session and must disappear automatically when the session ends. Which approach meets this requirement?
- AExport the results to a comma-delimited file and reopen it in the next session
- BCreate the data set with a one-level name so that it is written to the WORK library
- CStore the data set in a permanent library that was assigned with a LIBNAME statement
- DStore the data set in the SASHELP library so that it is removed when the session ends
Show answer and explanationHide answer
Correct answer: BThe WORK library is the default temporary library, and its data sets are deleted when the SAS session ends. A permanent library keeps its data sets after the session, an exported CSV file is a copy outside SAS, and SASHELP holds SAS-supplied sample data rather than session output.
Question 10
Which statement about the two-level data set name orders.sales_2023 is correct?
- AThe first level, orders, is the library reference and sales_2023 is the data set name
- BThe first level, orders, is the data set name and sales_2023 is the library reference
- CTwo-level names can refer only to SAS views, not to stored data sets
- DThe name is valid only when the library reference is WORK or SASHELP
Show answer and explanationHide answer
Correct answer: AIn a two-level name, the first part is the library reference that points to a library and the second part is the member name. Reversing the two levels, limiting names to views, or restricting them to WORK and SASHELP are all incorrect.
Question 11
A customer table holds one row per customer and an orders table holds many rows per customer. Both tables are sorted by customer ID. The team needs one output row per order with the customer's name and region added. Which DATA step approach is correct?
- AUse a SET statement that lists both tables, which places the customer columns beside each order row automatically
- BUse a MERGE statement with no BY statement, which matches rows on customer ID automatically
- CUse a MERGE statement with a BY statement on customer ID so each order row gets its customer values
- DUse PROC APPEND to add the customer rows to the end of the orders table
Show answer and explanationHide answer
Correct answer: CA MERGE with a BY statement performs a match-merge on the sorted key, bringing customer values onto each matching order row. SET stacks the tables vertically instead of adding columns, a MERGE without BY pairs rows by position rather than by key, and PROC APPEND adds rows to a base table.
Question 12
An analyst prints a SAS date variable without a date format and sees the value 0. Which calendar date does this value represent?
- AJanuary 1, 1970
- BDecember 31, 1959
- CJanuary 1, 1960
- DJanuary 1, 1900
Show answer and explanationHide answer
Correct answer: CSAS stores a date as the number of days since January 1, 1960, so the value 0 is that date. January 1, 1970 is the Unix epoch, December 31, 1959 is the day before the SAS base date (value -1), and January 1, 1900 is not the SAS base date.
Question 13
A programmer needs to test a step on the first 100 observations of a very large permanent data set without reading the rest of the data. Which SET statement does this?
- ASET perm.bigdata (OBS=100);
- BSET perm.bigdata (KEEP=id name);
- CSET perm.bigdata (WHERE=(id <= 100));
- DSET perm.bigdata (FIRSTOBS=100);
Show answer and explanationHide answer
Correct answer: AThe OBS= data set option stops reading after the given observation number, so only the first 100 observations are read. FIRSTOBS= begins reading at a later observation, KEEP= selects variables rather than rows, and a WHERE= test on id values filters by content rather than by position.
Question 14
A large cumulative history data set receives a small batch of new rows each month. The team wants to add the batch to the end of the history without rewriting the whole history data set. Which approach should they use?
- ARun a DATA step with SET history newbatch to create a new history data set
- BRun PROC APPEND with BASE=history and DATA=newbatch to add rows to history
- CRun PROC SORT with NODUPKEY on the history data set, sorted by its key
- DRun a DATA step with MERGE history newbatch and a BY statement on the key
Show answer and explanationHide answer
Correct answer: BPROC APPEND adds the observations of the DATA= data set to the end of the BASE= data set, so the large history is not copied. A SET step rewrites every observation into a new data set, while PROC SORT with NODUPKEY and a BY-based MERGE do not append rows.
Question 15
Which TWO procedures are used to investigate the contents of a SAS library or data set? (Choose two.)
- APROC CONTENTS
- BPROC SORT
- CPROC DATASETS
- DPROC MEANS
Show answer and explanationHide answer
Correct answer: A, CPROC CONTENTS reports variable names, types, lengths and observation counts for a data set, and PROC DATASETS lists the members of a library and can show their contents. PROC SORT reorders observations and PROC MEANS calculates statistics, so neither is used to investigate a library's structure.
Question 16
A programmer concatenates January and February sales tables with one SET statement and must know, for each row, which month's table supplied it. Which technique provides this?
- AUse a KEEP= option on each input table so that only the month column is retained
- BGive each input table an IN= option and test the temporary variable it creates in the DATA step
- CAdd a BY statement on the sales amount so that rows are grouped by the month that supplied them
- DRun PROC APPEND twice so that the source of each row is stored in the base table automatically
Show answer and explanationHide answer
Correct answer: BThe IN= data set option creates a temporary variable that is 1 when that input supplied the current observation and 0 otherwise, so it can be tested in an IF statement. KEEP= selects variables, a BY statement on sales reorders the rows instead of tracking their origin, and PROC APPEND does not record where each row came from.
Error Handling (7 questions)
Question 17
A DATA step assigns grades with three separate IF statements in this order: if score >= 90 then grade = 'A'; if score >= 80 then grade = 'B'; if score >= 70 then grade = 'C';. A student with a score of 95 ends up with grade C. Which change corrects this logic error?
- AChange each >= operator to an equals sign so that only exact scores match a grade
- BMove the grade assignments into a separate PROC step that runs after the DATA step
- CUse IF-THEN with ELSE IF so that only the first true condition assigns a grade
- DDeclare grade as a numeric variable with a LENGTH statement placed before the first IF
Show answer and explanationHide answer
Correct answer: CEach separate IF is tested independently, so a score of 95 satisfies all three conditions and the last assignment, C, overwrites the A. An IF-THEN with ELSE IF stops at the first true condition and gives 95 the grade A, while changing the operators, moving code to another step, or changing the data type does not stop the overwriting.
Question 18
Which description best distinguishes a syntax error from a logic error in a SAS program?
- AA syntax error breaks SAS language rules, such as a misspelled keyword, and the log reports it, while a logic error gives wrong results
- BA syntax error produces wrong output without a log message, while a logic error always stops the step with an ERROR message
- CA syntax error appears only in PROC steps, while a logic error appears only in DATA steps and is always reported as a warning
- DA logic error is a missing semicolon that merges two statements together, while a syntax error is a wrong comparison such as using < where > was intended
Show answer and explanationHide answer
Correct answer: ASyntax errors break the language rules, so SAS reports them in the log and the affected step does not run as intended. Logic errors are valid code that does not match the programmer's intent, so the step may run normally and produce wrong values.
Question 19
A DATA step contains the line total = amount + 5 with no semicolon at the end, and the next line begins with flag = 'Y';. What is the most likely result?
- ASAS reads both assignments as one statement, which usually causes a syntax error
- BSAS ignores the total assignment and runs the flag assignment with no message
- CSAS inserts the missing semicolon on its own and runs the step without any message
- DSAS sets every variable in the step to missing and writes a note to the log
Show answer and explanationHide answer
Correct answer: ASAS ends a statement only at a semicolon, so the two assignments merge into one invalid statement and the log shows an error. SAS does not insert semicolons, silently skip statements, or blank out every variable in the step.
Question 20
A DATA step contains if income < 50000 then band = 'Low'; and some observations have a missing income value. What happens to an observation whose income is missing?
- AThe comparison is false, so band stays missing for that observation
- BMissing is smaller than any number, so the comparison is true and band becomes Low
- CThe observation is dropped from the output data set automatically
- DSAS stops the step with a syntax error as soon as it reads the first missing income value
Show answer and explanationHide answer
Correct answer: BIn comparisons SAS treats a missing numeric value as smaller than any number, so missing income < 50000 is true and band is set to Low. The other options assume missing values make the comparison false, cause a syntax error, or remove the observation, which SAS does not do here.
Question 21
Which TWO actions help a programmer find logic errors in a DATA step? (Choose two.)
- AAdd PUT statements that write key variable values to the log at important points
- BRun the step on a small sample by adding OBS= to the SET statement and inspect the output
- CRemove the RUN statement so that the step continues into the following PROC step
- DIgnore NOTE messages in the log, because they never point to a problem with the data
Show answer and explanationHide answer
Correct answer: A, BPUT statements show variable values as the step executes, and a small OBS= sample makes it easier to trace each observation through the logic. Removing RUN merges the next statements into the current step rather than fixing the logic, and NOTE messages about missing values often reveal the cause of wrong results.
Question 22
The SAS log shows the note 'Missing values were generated as a result of performing an operation on missing values' for a DATA step. What does this indicate?
- AThe step failed, and no output data set was created
- BA macro variable referenced in the step was never defined
- CA calculation used a missing value as an operand, so the result was set to missing
- DThe data set was sorted in descending order when the program required ascending order
Show answer and explanationHide answer
Correct answer: CThis note means that an arithmetic or function operation received a missing operand and returned a missing result, and the step still completes. The other options describe a failed step, an undefined macro reference, or a sort-order problem, none of which this note reports.
Question 23
A numeric variable is read from raw text with an INPUT statement, and the log shows an invalid data note for that variable. Which result is typical for the affected observation?
- AThe observation is removed from the output data set and no record is kept
- BThe value is stored as a character string in the numeric variable
- CThe value is set to missing for that observation, and _ERROR_ is set to 1
- DThe value is converted to zero and the step stops at the first invalid row
Show answer and explanationHide answer
Correct answer: CWhen a numeric field holds text that cannot be read as a number, SAS sets that variable to missing and sets the automatic variable _ERROR_ to 1 for that iteration. Text cannot be stored in a numeric variable, the value is not converted to zero, and the step does not stop at the first invalid row.
Generate Reports and Output (7 questions)
Question 24
A report lists customer names and balances with PROC PRINT, but the printed output should not show the Obs column on the left. Which option meets this requirement?
- ANOOBS, which suppresses the observation number column in PROC PRINT output
- BNOCUM, which suppresses the cumulative columns in a frequency table
- CNODUPKEY, which removes rows that share the same BY values in PROC SORT
- DNOPERCENT, which suppresses the percent columns in a frequency table
Show answer and explanationHide answer
Correct answer: ANOOBS in PROC PRINT suppresses the observation-number column. NOCUM and NOPERCENT are PROC FREQ options for frequency tables, and NODUPKEY is a PROC SORT option, so none of them affects the Obs column in PROC PRINT.
Question 25
An analyst wants a two-way frequency table that shows how the counts of Product are split across the values of Region in one table. Which statement belongs in the PROC FREQ step?
- ACLASS region product;
- BBY region product;
- CTABLES region*product;
- DWEIGHT product;
Show answer and explanationHide answer
Correct answer: CThe TABLES statement with an asterisk requests a two-way crosstabulation in a single table. BY produces separate listings for each group, CLASS is used by summary procedures such as PROC MEANS, and WEIGHT changes how observations are counted rather than building a cross-tab.
Question 26
A character variable Gender holds the codes M and F. An analyst wants reports to display Male and Female while the stored values stay M and F. Which approach meets this requirement?
- AUse a RENAME= data set option to change the stored values M and F to Male and Female
- BUse a LENGTH statement that gives Gender a width large enough for the words Male and Female
- CUse a KEEP= data set option that lists Male and Female as the variables to retain
- DCreate a character format with PROC FORMAT and assign it to Gender in a FORMAT statement
Show answer and explanationHide answer
Correct answer: DA user-defined format changes only how values are displayed, so the stored M and F remain unchanged. RENAME= changes variable names rather than values, LENGTH controls storage width, and KEEP= selects variables, so none of them displays new labels for the codes.
Question 27
A programmer places a TITLE statement before a PROC PRINT step, and a PROC MEANS step follows later in the program. Which statement about the title is correct?
- AThe title remains in effect for later output until it is replaced or canceled
- BThe title applies only to the PROC PRINT step and is removed automatically when that step ends
- CEach later PROC step must repeat the title, because titles cannot persist between steps
- DThe title is stored as a variable in each output data set created by the steps
Show answer and explanationHide answer
Correct answer: AA TITLE statement stays in effect across later steps until another TITLE is submitted or the titles are cancelled. Titles are not stored as data set variables, and the end of a PROC step does not remove them.
Question 28
An analyst opens an ODS HTML destination, runs two procedures into it, and then needs the HTML file to be completed and closed. Which statement should be submitted?
- AENDSAS; which ends the entire SAS session right away and stops all further program steps
- BODS HTML CLOSE; which closes the destination and finishes writing its output file
- CRUN; QUIT; which end the current steps but leave the destination open
- DOPTIONS NOSOURCE; which suppresses the source program lines in the log
Show answer and explanationHide answer
Correct answer: BAn ODS destination must be closed with ODS HTML CLOSE to finish the output file. ENDSAS ends the whole session, RUN and QUIT only end individual steps while the destination stays open, and OPTIONS NOSOURCE changes only the log display.
Question 29
An analyst needs the average sales for each region, with one line of output per region. Which step does this?
- APROC PRINT DATA=sales; ID region; VAR sales; RUN;
- BPROC SORT DATA=sales NODUPKEY; BY region; RUN;
- CPROC FREQ DATA=sales; TABLES region*sales; RUN;
- DPROC MEANS DATA=sales MEAN; CLASS region; VAR sales; RUN;
Show answer and explanationHide answer
Correct answer: DPROC MEANS with a CLASS statement computes the requested statistic for each combination of CLASS values, giving one line per region. PROC PRINT lists every observation, PROC FREQ counts combinations rather than averaging sales, and NODUPKEY keeps one row per region without computing an average.
Question 30
An analyst wants to include only one specific table from a procedure's output in an ODS destination, but does not know the internal name of that table. Which statement reveals the object names so that the table can be selected?
- AODS TRACE ON;
- BODS EXCLUDE ALL;
- CODS HTML CLOSE;
- DOPTIONS NOSOURCE;
Show answer and explanationHide answer
Correct answer: AODS TRACE ON writes the path and name of each output object to the log, and those names can then be used in an ODS SELECT statement. ODS EXCLUDE ALL suppresses every table, ODS HTML CLOSE ends a destination, and NOSOURCE affects only how program lines appear in the log.