Skip to contents

XPT Transport I/O

Read and write SAS V5/V8 transport files in pure R — no SAS, no haven, no compiled code. Auto-computes lengths, preserves all metadata, handles date/datetime conversion and character encoding.

read_xpt()
Read a SAS Transport (XPT) file into a data frame
write_xpt()
Write a data frame to a SAS Transport (XPT) file

Dataset-JSON I/O

Read and write CDISC Dataset-JSON v1.1 files. Convert between XPT and Dataset-JSON formats with full metadata preservation.

read_json()
Read a CDISC Dataset-JSON file
write_json()
Write a data frame as CDISC Dataset-JSON v1.1
xpt_to_json()
Convert an XPT file to Dataset-JSON
json_to_xpt()
Convert a Dataset-JSON file to XPT

Specification Objects

Create, read, write, and inspect herald_spec objects — the single source of truth for dataset structure, variable metadata, codelists, and study information. Supports P21 Excel, Define-XML 2.1, and JSON.

herald_spec()
Create a clinical dataset specification
read_spec()
Read a clinical dataset specification
write_spec()
Write a herald specification to JSON
read_spec_define()
Read a Define-XML specification

Spec Accessors

Query specific parts of a specification: dataset names, variable definitions, codelists, and study-level metadata.

spec_datasets()
Get dataset names from a specification
spec_vars()
Get variable metadata for a dataset
spec_codelist()
Get codelist entries
spec_study()
Get study metadata value

Metadata Helpers

Set and get variable-level and dataset-level metadata attributes: labels, SAS formats, storage lengths, and dataset labels. All helpers support tidy evaluation and pipe-friendly usage.

set_label()
Set or get variable labels
set_format()
Set or get SAS display formats
set_length()
Set or get SAS storage lengths
set_dataset_label()
Set dataset label
get_metadata()
Get all metadata for a data frame

Spec Application

Apply a specification to a data frame: scaffold missing variables, drop unspecified columns, coerce types, set attributes, order columns, sort by keys, and decode coded values. apply_spec() runs all steps; individual functions provide granular control.

apply_spec()
Apply a specification to a data frame
scaffold_vars()
Add missing spec variables as typed NA columns
drop_unspec_vars()
Drop columns not defined in the specification
coerce_types()
Coerce column types to match the specification
order_cols()
Reorder columns to match the specification
sort_keys()
Sort a data frame by spec key variables
decode_var()
Decode a coded column using spec codelist

Define-XML 2.1

Generate valid Define-XML 2.1 documents with full namespace support (ODM 1.3, Define-XML extensions, ARM 1.0). Render to HTML for reviewer-friendly display. Validate generated XML against DD rules.

write_define_xml()
Write a Define-XML 2.1 file from a herald specification
write_define_html()
Write a Define-XML 2.1 HTML rendering
validate_spec_define()
Validate a herald_spec against Define-XML rules (DD0001–DD0085)

Validation Engine

Check datasets against a specification and conformance rules. Built-in spec checks catch structural issues; CDISC CORE, FDA, and PMDA rule sets provide regulatory-grade conformance checking.

validate()
Validate clinical datasets
validate_spec()
Validate a herald_spec against Define-XML rules
validation_report()
Export a validation report
verify_html_report()
Open a validation report in the IDE Viewer
new_herald_context()
Create a validation context
build_anchor_index()
Build an anchor index from an anchor dataset

Rule Management

Browse, fetch, and configure validation rule sets. Supports bundled herald rules, CDISC CORE rules, and custom operator extensions. Rule YAML definitions live in the heraldrules repository — report rule bugs or request new rules there.

rule_catalog()
Browse available validation rules
rule_config()
Select a validation rule configuration
fetch_herald_rules()
Fetch herald rules from GitHub
fetch_core_rules()
Fetch CORE rules from the CDISC Library API
update_core_rules()
Update cached CORE rules
herald_rules_cache_dir()
Return the cache directory used by herald for validation rules
register_operator()
Register a CORE check operator
load_herald_config()
Load a herald config and its associated rules from cache
register_ct()
Register custom controlled terminology
clear_ct()
Remove all registered custom controlled terminology
list_ct()
List registered custom controlled terminology packages

Built-in Rule Sets

Pre-packaged conformance rules for specific regulatory authorities and standards. Return lists of herald_rule objects.

fda_rules()
Get FDA Business Rules
adam_rules()
Get ADaM rules
pmda_rules()
Get PMDA rules

Submission Packaging

One-call submission packaging: validate, generate Define-XML, produce reports, and build a manifest with SHA-256 checksums. Supports format conversion and eCTD-compatible output directory layout.

submit()
Package a complete regulatory submission
detect_adam_class()
Detect the ADaM dataset class from column names
detect_adam_classes()
Detect ADaM class for each dataset in a named list or spec