Skip to contents

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

Value

Returns a character vector of failed conditions

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.