Huru
Technical Interviews

SAS Interview Questions and Answers (2026)

SAS interview questions with short answers and code: the DATA step and PROC steps, libraries, SET and MERGE, WHERE vs IF, how SAS stores dates, RETAIN and FIRST./LAST., INPUT vs PUT, PROC SORT, PROC TRANSPOSE, PROC SQL, macros, debugging, and what the Base Programming certification covers.

By Amine Boukioud Updated 5 min read
The Huru mascot at a desk pointing at a monitor where two small colored tables merge into one larger table next to a bar chart, with two stacks of blocks joining above

The short answer: SAS interviews test whether you can read, combine, clean and summarize data correctly, and find your own errors. The core topics match SAS’s own Base Programming certification guide: creating and accessing data sets, combining them (concatenating and merging), conditional processing, functions for text, numbers and dates, accumulating totals with BY groups, reports with PROC PRINT, MEANS and FREQ, and debugging with the log. Experienced roles add PROC SQL, macros and performance. Below are the common questions with short answers and code.

What SAS’s certification covers

SAS’s exam content guide for the SAS 9.4 Base Programming exam groups the skills into four areas: Access and Create Data Structures (20–25%), Manage Data (35–40%), Error Handling (15–20%), and Generate Reports and Output (15–20%). It’s a good checklist for interview preparation even if you aren’t taking the exam.

Fundamentals

“What’s the difference between a DATA step and a PROC step?”

The DATA step reads and creates data sets, row by row. PROC steps run procedures on existing data, such as sorting, summarizing, reporting or modeling.

“What is a library?”

A reference to a location holding SAS data sets, assigned with LIBNAME. WORK is temporary and deleted at the end of the session; a permanent library keeps data sets.

libname proj "/data/project";
data proj.customers_clean;
  set proj.customers;
run;

“How does SAS store dates?”

As numbers: the number of days since January 1, 1960. Informats read dates in, formats display them, and functions such as INTCK, INTNX and YRDIF calculate with them.

Combining data

“What’s the difference between SET and MERGE?”

SET with several data sets stacks (concatenates) them. MERGE with a BY statement joins them side by side by key. Both inputs must be sorted (or indexed) by the BY variables.

proc sort data=orders; by customer_id; run;
proc sort data=customers; by customer_id; run;

data combined;
  merge customers(in=a) orders(in=b);
  by customer_id;
  if a and b;   /* keep matches only, like an inner join */
run;

“What happens with a many-to-many merge?”

A DATA step merge doesn’t produce all combinations and writes a note to the log; use PROC SQL when you need a true many-to-many join.

“When would you use PROC SQL instead of a DATA step merge?”

When you need joins on different variable names, many-to-many joins, no pre-sorting, or summaries in one query. A DATA step can be clearer for row-by-row logic.

Conditional processing

“What’s the difference between WHERE and IF?”

WHERE filters observations before they’re read into the DATA step, works in PROCs and can use indexes, but only on variables that already exist in the input. A subsetting IF filters after the row is read, so it can use variables you create in the step.

“DROP and KEEP statements vs DROP= and KEEP= options?”

Statements affect the output data set. Data set options on an input control which variables are read, which can save processing.

Accumulating values

“How do RETAIN and FIRST./LAST. work?”

RETAIN keeps a variable’s value across iterations instead of resetting it to missing. With a BY statement, FIRST.var and LAST.var flag the start and end of each group.

data totals;
  set sales;
  by region;
  if first.region then region_total = 0;
  region_total + amount;   /* sum statement implies RETAIN */
  if last.region then output;
run;

Functions and conversion

“What’s the difference between INPUT and PUT?”

INPUT converts character to numeric (using an informat); PUT converts numeric to character (using a format). Relying on automatic conversion writes notes to the log and can cause errors.

“Name some character functions.”

SCAN, SUBSTR, TRIM, COMPRESS, UPCASE, LOWCASE, plus CATX for concatenation and INDEX or FIND to search.

Procedures

  • PROC SORT: NODUPKEY removes rows with duplicate BY values; NODUPRECS removes identical consecutive rows; OUT= writes to a new data set.
  • PROC MEANS and PROC FREQ: summary statistics and frequency tables, by group with CLASS or BY.
  • PROC TRANSPOSE: reshape long to wide or wide to long, with VAR, ID and BY.
  • ODS: send output to HTML, PDF, RTF or Excel files.

Macros

“What’s a macro variable, and when do you use macros?”

%LET creates a macro variable you reference with &name, to avoid hard-coding values such as dates. %MACRO and %MEND define reusable code blocks with parameters. Use a period to end a macro variable name when text follows it, as in &year.Q1.

Debugging

“How do you find errors in a SAS program?”

Read the log: errors, warnings and notes such as uninitialized variables, character-to-numeric conversion, or missing values generated. Use PUTLOG in the DATA step to print values and trace logic, and test on a small subset.

Scenario and behavioral questions

  • “A merge produced more rows than expected. What do you check?” Duplicate keys in one or both data sets.
  • “Your report totals don’t match finance’s numbers. How do you investigate?” Compare filters, date ranges, missing values and duplicates step by step.
  • “Tell me about an analysis that changed a decision.” See solving a complex problem.

In clinical research and pharmaceutical roles, expect questions on CDISC data standards (SDTM and ADaM) and validation. See also our data engineer interview questions.

Frequently asked questions

What SAS questions are asked in interviews?
Questions on the DATA step and PROC steps, libraries, SET and MERGE, WHERE vs IF, how SAS stores dates, RETAIN and FIRST./LAST. processing, INPUT vs PUT, PROC SORT, MEANS, FREQ and TRANSPOSE, PROC SQL, macros, and debugging with the log.
What is the difference between WHERE and IF in SAS?
WHERE filters observations before they are read and can use indexes, but only on existing variables. A subsetting IF filters after a row is read, so it can use variables created in the DATA step.
How does SAS store dates?
As the number of days since January 1, 1960. Formats display them as readable dates, and functions such as INTCK and INTNX calculate intervals.
What is the difference between SET and MERGE in SAS?
SET with several data sets stacks them; MERGE with a BY statement joins them side by side by key, and both inputs must be sorted or indexed by the BY variables.
What does the SAS Base Programming certification cover?
SAS's exam content guide lists four areas: accessing and creating data structures, managing data, error handling, and generating reports and output.

Sources

Practice this with Huru AI

Turn what you just read into a rehearsal. Unlimited AI mock interviews with instant, specific feedback.

Amine Boukioud

Amine Boukioud is Head of Growth at Huru and writes Huru’s company interview guides. Each one starts from the company’s own careers pages and what candidates report, and follows Huru’s editorial policy.

Published · Updated

How this article was made: researched and drafted with AI assistance, then written, fact-checked and signed by Amine Boukioud on October 1, 2026. Sources are linked where they are used. How we work: editorial policy.