Short answer
Yes — for a fair share of day-to-day “Base SAS” data-crunching jobs you can swap in DuckDB and get comparable (often better) performance at zero licence cost.
No — if you rely heavily on the DATA-step language, SAS-formats/informats, the SAS macro facility, or need everything to behave exactly the way SAS does, you’ll either have to (a) re-engineer that logic in SQL / Python / R or (b) keep a small SAS footprint.
Below is a practical deep-dive so you can judge where your own workloads sit on that spectrum.
Feature-by-feature comparison (Base SAS vs DuckDB)
Area
Base SAS (DATA-step + PROC SQL etc.)
DuckDB 0.9.x (in-process DB)
Notes / Gaps
Core language
DATA-step (row-wise), PROC SQL, macros
ANSI SQL 2003+ plus extensions, Python/R embedding, UDFs
DATA-step logic must be rewritten in SQL or a host language
File formats
Native .sas7bdat, wide I/O support (CSV, Excel, ODBC, …)
No native .sas7bdat read; convert first (e.g. via pyreadstat).
Merging & joins
MERGE statement (BY=), PROC SQL joins
INNER / LEFT / RIGHT / FULL join; partition/over, etc.
For classic BY-group MERGE, recode as SQL join or window functions.
Grouped stats
PROC SUMMARY/MEANS, FREQ, TABULATE
GROUP BY, COUNT(*), window agg, CUBE/ROLLUP
Nearly 1-to-1 mapping in SQL; performance very strong.
Sorting
PROC SORT; sorts often mandatory before BY=
ORDER BY; automatic hash-/merge-based sort
DuckDB doesn’t force a prior sort before aggregation; fewer steps.
Formats/informats
$CHAR., BEST., custom formats
Not implemented
Emulate with CAST, printf, lookup tables, or host code.
Missing value semantics
SAS numeric missings . .A–.Z > any number
Standard SQL NULL
Slight behavioural differences in comparisons/ordering.
Scalability
SMP, multi-threaded, can spill to disk, mature memory mgmt
Columnar, vectorised, can out-of-core, single-host only
DuckDB maxes out at single machine; no clustered mode (yet).
Logging / audit trail
PROC PRINTTO, SAS logs, ERROR/NOTE lines
Basic client logs; you must script your own audit trail
Enterprises with strict audit needs may need extra plumbing.
Scheduling & batch
sas -sysin prog.sas, LSF/Grid Manager
duckdb -c "SQL", cron, Airflow, …
Similar, but you’ll script around DuckDB CLI or Python/R entry.
Licensing
Commercial
MIT (free)
—
When the swap is almost plug-and-play
You’ll likely be happy with DuckDB if your SAS work is mostly:
• PROC SQL queries, joins, unions, CTEs, window functions
• PROC MEANS/SUMMARY/FREQ style aggregations
• Light-weight data reshaping (wide⇄long) that can be expressed in SQL
• Reading / writing flat-files, Parquet, Excel, S3, etc.
• Running on a single beefy workstation or VM rather than an MPP grid
These translate to straight SQL that DuckDB already excels at, often 2-10× faster due to its columnar in-memory execution and Parquet “zero-copy” reads.
Where you’ll hit friction
• DATA-step loops, arrays, FIRST./LAST. BY-group logic, RETAIN…
– You’ll rewrite into SQL window functions or a host-language (Python, R, C++ UDF, etc.).
• Complex SAS macros generating code on the fly
– Templating or procedural generation must move to Jinja₂, Python functions, dbt, …
• Custom formats / informats and the “order-ahead” missing values (.A > .)
– Need bespoke handling.
• PROD environments that depend on SAS/Connect, Workspace servers, metadata server, scheduled flows in SAS MC
– Requires a new orchestration layer (Airflow, Prefect, dbt, etc.).
• Regulatory or audit requirements that assume SAS logs & PROC printouts
– You’ll design new logging around DuckDB (e.g. capturing stdout, query plans).
Typical migration recipe
Catalogue current code
• Classify each program: “pure PROC SQL”, “light DATA-step”, “heavy macro”, etc.
Convert data sets
• Use pyreadstat, haven, or SAS export to Parquet/CSV.
Re-implement logic
• Simple → rewrite as DuckDB SQL.
• Complex → embed DuckDB in Python/R and keep the tricky bits in Pandas/Polars.
Validate
• Row counts, checksums, extreme-value spot-checks → flag diffs in NULL vs missing.
Automate & schedule
• Wrap in scripts, notebooks, dbt models, or Airflow DAGs; capture query plans (EXPLAIN ANALYZE).
Decommission or downsize SAS licence once parity is proven.
Quick code translation example
SAS DATA-step merge:
sas
proc sort data=left; by id; run;
proc sort data=right; by id; run;
data joined;
merge left(in=a) right(in=b);
by id;
if a and b;
run;
DuckDB SQL:
sql
CREATE TABLE joined AS
SELECT *
FROM left l
JOIN right r USING (id);
(If you need the in= flags, add l.* , r.* , l.id IS NOT NULL AS in_left , r.id IS NOT NULL AS in_right.)
Performance snapshot
• 100 M row Parquet, GROUP BY customer_id → DuckDB ~2–3 s (laptop SSD)
• Same in Base SAS PROC SQL (imported data set) → ~6–10 s (depends on compress=yes, indexes, …)
Your mileage will vary, but DuckDB’s vectorised engine is generally quicker for read-heavy analytics.
Verdict
Feasible, and a growing number of shops are doing it—especially when:
✓ The workload is analytical, not operational/transactional.
✓ You’re prepared to refactor legacy DATA-step or macro logic.
✓ Single-node scale (up to 100s GB/low TB) is fine.
✓ Cost avoidance is a strong driver.
Not feasible (without major re-engineering) when you need:
✗ DATA-step semantics preserved 1-for-1, including SAS formats/informats.
✗ Multi-user app server environment with SAS metadata & scheduling baked in.
✗ Enterprise audit expectations tied to SAS’s specific log output.
If you land in the “mostly PROC SQL + summary” camp, DuckDB is a compelling, low-friction replacement. If you’re deep in DATA-step macro land, view DuckDB as one piece of a broader modern stack—great for the heavy lifting, but you’ll still need some glue code around it.