Search notes:

SAS: proc format

proc format can be used to create a customized format besides the ones provided by SAS.

Creating a range format

proc format;
  value BMI
        low  - 18.5 = "Underweight"
        18.5 - 25   = "Normal weight"
        25   - 30   = "Overweight"
        30   - high = "Obese";
run;


data _null_;
  format w1-w4 BMI.;

  w1 = 22;
  w2 = 17;
  w3 = 30;
  w4 = 31;

  put w1-w4;
 
run;
Github repository about-SAS, path: /programming/proc/format/value.range.sas

Formatting a date time

The following picture allows to display a date time as dd.mm.yyyy hh24:mi:ss:
proc format;
  picture
     ddmmyyyy_hh24miss 
    (default=19)                   /* <-- default width of format */
     other='%0d.%0m.%Y %0H:%0M:%0S'
    (datatype=datetime);
  
run;

data _null_;
  dt='9mar2018 7:2:25'dt;
  put dt ddmmyyyy_hh24miss.; /* 09.03.2018 07:02:25 */
run;
Github repository about-SAS, path: /programming/proc/format/picture/ddmmyyyy_hh24miss.sas
It looks as though the formats are somehow modelled after strftime.
See also the datetime. format.

See also

SAS programming: proc
proc format can be used to create colors for a traffic lights report.

Index