Informats and formats are used to tell SAS how to read and write the data respectively. Informats are commonly used in a datastep when reading data from an external file. Informats are rarely used in PROCs. Formats are commonly used in both data steps and PROCs.
SAS Formats convert either numeric or character values to character values. A format can either be applied using a format
or put
statement, which changes the way a value is displayed, or using the put
function to store the formatted value in a new variable.
There are four categories of formats :
Formats usually take the form <formatname><w>.<d>;
, w
being the width (including any decimals and the point), d
being the number of decimal places.
Common date formats (applied to SAS date values) :
date9.
e.g. 02AUG2016ddmmyyn8.
e.g. 02082016ddmmyy8.
e.g. 02/08/16yymmdd10.
e.g. 20160802year4.
e.g. 2016Common numeric formats (applied to numbers) :
comma11.0
e.g. 1,234,567comma12.2
e.g. 1,234,567.00dollar11.2
e.g. $5,789.12nlmnlgbp11.2
e.g. £2,468.02Other formats :
$hex8.
, convert string to hex$upcase.
, convert string to upper-case$quote.
, enclose a string in quotesA full list of formats can be found here > https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001263753.htm