Exampler.org SAS PYTHON HTML
SAS Introduction
SAS Abs
SAS Anydigit
SAS ASC
SAS Case Stmnt.
SAS Ceiling
SAS Change type
SAS Char
SAS CMISS
SAS Coalesc
SAS Coalescec
SAS Concatenate
SAS Constant
SAS Create Table
SAS DateTime
SAS Day
SAS Find
SAS Floor
SAS HMS
SAS Holiday
SAS HOUR
SAS Import
SAS Informats
SAS Inobs
SAS Input Stmt.
SAS Int
SAS INTNX
SAS Length
SAS Libname
SAS Loops
SAS Minute
SAS Month
SAS MDY
SAS NMISS
SAS Notdigit
SAS Lowercase
SAS Outobs
SAS Put Stmt.
SAS Rename
SAS Round
SAS Scan
SAS Substr
SAS Sum
SAS STNAME
SAS STNAMEL
SAS Time
SAS Trunc
SAS Uppercase
SAS Week
SAS Year
SAS Financial Functions
SAS Compound

SAS PUT Statement

What is it?

Syntax:

  • PUT(source, format.);

SAS PUT Statement:


 SAS PUT Statement Example:




Data work.my_data_file;

    Result_1 = PUT(2021.6666667, fract8.);
    Result_2 = PUT(2021.6666667, Binary8.);
    Result_3 = PUT(2021.6666667, Dollar.5);
    Result_4 = PUT(2021.6666667, Dollar.);
    Result_5 = PUT(2021.6666667, Dollarx.);
    Result_6 = PUT(.21, Percent.2);
    Result_7 = PUT(2021, words25.);
    Result_8 = PUT(2021, Roman5.);
    Result_9 = PUT(2021, Hex5.);
    Result_10 = PUT(58513.064103, nltimap15.);
    Result_11 = PUT(43402, Time.);
    Result_12 = PUT(1934061623.7, nldatm.);
    Result_13 = PUT(1934150400, datetime19.);
    Result_14 = PUT(22401, date.);

Run;





What's happening in the script above?

  • The PUT function takes an input and reformats the output into a wide variety of possibilities.
  • The function examples below are solely Numeric, however there are several other types [Section Needs Improvement]


PUT Statement Examples:

Variable Input Output Format
Result_1 2021.6666667 2021+2/3 Fract8.
Result_2 2021.6666667 11100101 Binary8.
Result_3 2021.6666667 2021.7 Dollar.5
Result_4 2021.6666667 $2,022 Dollar.
Result_5 2021.6666667 $2.022 Dollarx.
Result_6 .21 21% Percent.2
Result_7 2021 two thousand twenty-one words25.
Result_8 2021 MMXI Roman5.
Result_9 2021 007E5 Hex5.
Result_10 58513.064103 from Time() 04:15:13 PM nltimap15.
Result_11 43402 from HMS() 12:03:22 Time.
Result_12 1934061623.7 from DateTime() 14Apr2021:23:20:24 nldatm.
Result_13 1934150400 from INTNX() 16Apr2021:00:00:00 datetime19.
Result_14 22401 from INTNX() 01MAY21 date.

See also; Informat Function



Connect via LinkedIn

Kevin Regan

Have an article, idea, found a typo, want to contribute? Shoot me an email Here


Below are links to some Udemy Data Science Courses. I've been using Udemy for a number of years now, and I've found their courses super helpful, maybe you will also.