SAS Examples: Numeric/Character Conversions

Last updated:

WIP Alert This is a work in progress. Current information is correct but more content may be added in the future.

Convert a character value to a numeric value

proc sql;
    select input(<tbl_alias>.<char_field>,8.)
    from <namespace>.<full_table_name> as <tbl_alias>;

Convert a numeric value to a character value

proc sql;
    select put(<numeric-attribute>,7.)
    from <table>
    where <conditions>;

Pad a numeric value with leading zeros (as a character value)

Suppose <my_numeric_value> is a numeric SAS value. This will convert it to char and pad the value.

translate(right(put(<my_numeric_value>,9.0)),'0',' ')


Dialogue & Discussion