sas2r-agent
Built at Meta Global AI Developer Hackathon · Oct 26, 2026 · Remote

sas2r-agent translates clinical-trial SAS programs to R and tests whether the R reproduces the SAS output, number for number, with an audit trail a reviewer can verify. The problem: every clinical trial's datasets, tables, listings and figures are produced by SAS programs, and the biopharma industry is moving to R. Each legacy program has to be rewritten in R and then shown to give the same numbers as the original, because regulatory submissions depend on them. A script that runs cleanly can still produce wrong numbers, so the checking step (double programming) is 30 to 50 percent of all programming effort. I have been a clinical SAS programmer in pharma since 2008 and have worked in R since 2016. This is the bottleneck I work inside every week. What it does: given a SAS program and the outputs SAS produced, a context builder assembles the program, its input data and expected outputs. Muse Spark 1.3 (Meta Model API) writes one R script. A network-isolated Docker sandbox runs it. A comparator checks every R output against the frozen SAS reference (cell for cell for datasets, every number for tables and listings, presence for figures) and sends the differences and the R log back to Muse Spark for repair, up to three attempts. Every attempt is recorded in an append-only, hash-chained provenance ledger (SHA-256 of the prompt, the model answer, the script, the R log, every R output and the SAS reference files), and a verifier recomputes the whole chain. Results on a 100-program benchmark of public clinical SAS programs run in real SAS 9.4: Muse Spark 1.3 passes every check on 94 of 100, and on the 39 programs that produce datasets it matches 37 cell for cell, the same count as Claude Opus 5.5, at half the cost per passed program (about $0.09). Muse Spark Open (open weights) scores 85 on the same harness, so a sponsor can run the pipeline inside its own firewall. Prompt rules were derived from the agent's own misses across three prompt versions (86, 95, 94). All 1,500 generated scripts, comparisons and ledger entries are in the repo, with an interactive leaderboard. Built solo inside the hackathon window. The benchmark corpus and its SAS reference outputs are my pre-existing work and live in a separate public repo (sas2r-benchmark), referenced from the entry. Links: code and all 1,500 generated R scripts https://github.com/tomasantony/sas2r-agent ; benchmark corpus and SAS reference outputs https://github.com/tomasantony/sas2r-benchmark ; 3-minute demo https://youtu.be/OiryI10mUdU ; X post https://x.com/Tantony01/status/2118105604036145536