Skip to contents

When called with named arguments, sets the sas.length attribute on the specified columns. When called without arguments, returns current lengths. If no explicit length is set, write_xpt() auto-computes lengths from the data (8 for numeric, max byte width for character).

Usage

set_length(data, ...)

Arguments

data

A data frame.

...

Named arguments where names are column names and values are integer storage lengths.

Value

When setting: the data frame with updated length attributes. When getting: a named integer vector of lengths.

Examples

df <- data.frame(STUDYID = "S1", AGE = 65, stringsAsFactors = FALSE)
df <- set_length(df, STUDYID = 20L, AGE = 8L)
set_length(df)
#> STUDYID     AGE 
#>      20       8