makeSASNames: Create valid and unique SAS names from a character vector.

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Create valid and unique SAS names from a character vector.

Usage

1
makeSASNames(names, nchar = 8, maxPasses = 10, quiet=FALSE)

Arguments

names

character vector of candidate names

nchar

maximum number of characters

maxPasses

maximum number of interations to resolve truncation-related name duplication.

quiet

Logical indicating whether to generate warning messages when names are truncated or made unique.

Details

This function creates valid SAS names from a list of R object or column names, properly handling case conversion (all converted to upper-case), length restructions (8 characters), and making duplicate names unique. This is not as obvious as it appears, since the process of shortening names can cause duplicates, and adding digits to the end of names to make them unique can make them too long, so a few iterations may be required to ensure valid and unique names.

Value

character vector of unique names valid in SAS.

Author(s)

Gregory R. Warnes [email protected]

See Also

make.names

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
  ## Simple example: no duplicates or more than 8 characters
  makeSASNames( c("height","weight","age","gender"))

  ## Resolve duplicates
  makeSASNames( c("a","a","b","b","b","c") )

  ## Truncate long names
  makeSASNames( c("alphabetic", "numeric", "alphanumeric", "whitespace"))

  ## Truncate and make unique
  makeSASNames( rep( c("aaaaaaaaaaa","bbbbbbbbbb"), each=3) )

  ## Now do it quietly!
  makeSASNames( rep( c("aaaaaaaaaaa","bbbbbbbbbb"), each=3), quiet=TRUE)

SASxport documentation built on May 2, 2019, 4:51 p.m.