Rabidwolff's Alehouse
"Your place for fun and knowledge."
HOME | Quotes | SAS | C# | BEER



Basics
FORMATS
INFORMATS
DATETIME
ATTRIB
LENGTH
FORMAT
INFORMAT
LABEL
JOINS
OPERATORS

Statements
RETAIN
FIRST.
LAST.

Procedures
PROC SORT
PROC COPY
PROC CPORT
IF ELSE
PROC REPORT

Functions
CAT
CATS
CATT
CATX

CDISC
Random Q & A

CDISC
CDISC Info

Coded Tools
XML Output
Examples

Creating/Modifying Variable Attributes
(ATTRIB, LENGTH, FORMAT, INFORMAT, LABEL)

  • All SAS variables carry attributes that describe how much space they take up, data type, how to display or save values, as well as a brief description/purpose for the variable.
  • ATTRIB allows you set to all attributes of a variable at one time
  • Variable Name
    • CDISC allows up to 8 characters in length
    • Newer SAS versions allow up to 32 characters
    • Must start with an alpha character ‘A-Z’ or underscore ‘_’
    • Subsequent characters can be numbers also
    • Not case sensitive
    • You cannot use SAS reserved words, do not start with ‘SYS…’
    • Use RENAME statement to change a variable name
  • Data Type
    • Variables are either character (length starts with ‘$’ or numeric)
    • Default is numeric
  • Length
    • 1-32,767 for character
      • 1 byte per character (unless you use special multi-byte values)
      • 8 is the default, although if you set a field then it will take the length of the first data value set to it, truncating longer length values saved into later on
      • For special multi-byte data values (DBCS, Unicode, or UTF-8), where a character can occupy more than one byte, the number of characters that fit might be less than the length value of the column
    • For numeric values, the length is number of bytes allocated
      • 3 is the minimum for windows & UNIX environments
      • 8 is the default (values up 9,007,199,254,740,990)
      • Use smaller length if you really need to save disk space (sometimes every little bit counts)
  • Format
    • Default to whatever length is for first set character value for character
    • Can be set to a SAS format name
    • Defaults to BEST12. for numeric if not otherwise set
  • Informat
    • Default to whatever length is for first set character value for character
    • Can be set to a SAS informat name
    • Defaults to 12. for numeric if not otherwise set
  • Label
    • Just a descriptive term you can use to briefly tell the purpose of the variable
    • CDISC allows labels up to 40 characters in length
    • CDISC dictates all non-trivial words (more than three characters) must start with a capital letter with the rest of the characters lowercase
    • Newer SAS versions allow up to 256 characters
Click to Show Examples:

Rabidwolff Industries | Establisted: 10/15/2011 | Version: 4 8/4/2012 | Page Last Generatated: 9/25/2021 4:03:57 PM