xpt_validate: Validate Dataset Can be Written to xpt

View source: R/utils-xportr.R

xpt_validateR Documentation

Validate Dataset Can be Written to xpt

Description

Function used to validate dataframes before they are sent to haven::write_xpt for writing.

Usage

xpt_validate(data)

Arguments

data

Dataset to be exported as xpt file

Details

xpt_validate() performs four focused checks before xportr_write() attempts to create an XPT file:

  • Variable names – maximum of 8 characters, must start with a letter, use only ASCII alphanumeric characters (no underscores or symbols), and remain uppercase.

  • Variable labels – maximum of 40 characters and limited to ASCII printable characters.

  • Formats – SAS format attributes must match the internal allow-list or follow a w.d pattern such as 8. or 12.3.

  • Character data lengths – each character column's maximum byte length cannot exceed 200.

Value

Returns a character vector of failed conditions


xportr documentation built on Sept. 1, 2026, 9:07 a.m.