SAS Informat and the INFORMAT Statement

A SAS informat tells SAS how to interpret a source value when it is read into a variable. Informats are useful when raw data contains characters such as commas, currency symbols, date separators, or other patterns that cannot be read correctly with standard numeric or character input.

The INFORMAT statement associates one or more informats with variables in a SAS DATA step. SAS then uses those informats when it reads values for the variables, unless the INPUT statement supplies a different informat explicitly.

SAS Informat, Format, and Raw Data

TermPurposeExample
InformatConverts raw input into a SAS valueCOMMA10. reads 12,500 as the numeric value 12500
FormatControls how a stored SAS value is displayedCOMMA10. displays 12500 as 12,500
Raw dataThe text or binary value supplied to SAS18Jun2006, $7500, or 29/01/2010

An informat affects input conversion; it does not normally determine how the stored value is printed. Use a FORMAT statement when a date, time, currency amount, or other stored value needs a particular display style.

INFORMAT Statement Syntax

INFORMAT variable-1<informat-1> variable-N>;

In practical SAS syntax, place each variable or variable list before the informat that applies to it:

</>
Copy
INFORMAT variable-list informat.;

For example, the following statement permanently associates informats with three variables in the DATA step:

</>
Copy
informat name $20. salary comma12.2 start_date date9.;

An informat name usually ends with a period. The optional width specifies how many input columns or characters SAS should consider. Some numeric informats also accept a decimal specification, written as w.d.

INFORMAT Statement Versus an Informat in INPUT

Use the INFORMAT statement when an informat should be associated with a variable and reused during input. Use an informat directly in the INPUT statement when it is needed only at that point or when the raw record layout requires explicit input control.

</>
Copy
data payments;
    informat amount comma10.2 payment_date ddmmyy10.;
    input amount payment_date;
    format payment_date date9.;
datalines;
1,250.75 17/07/2026
980.00 18/07/2026
;
run;

The colon modifier provides another common approach. It tells SAS to use the specified informat while retaining list-input behavior:

</>
Copy
input variable : informat.;

Categories of SAS Informats

  1. Character informats
  2. Numeric informats
  3. Date, time, and datetime informats
  4. Column-binary informats
  5. User-defined informats

Character Informats in SAS

Character informats read source text into character variables. Character informat names begin with a dollar sign. The standard $w. informat reads a character field with a specified width, while informats such as $CHARw. preserve leading blanks within fixed-width fields.

The general character informat form is $informatw.. Examples include $10., $30., $100., and $CHAR20.. The terminating period is part of the informat name.

Character Informat Example Program

Data Informat01;
Infile datalines;
Input ID Name$ Age Sal;
Datalines;
001 David 29 40000
002 Amelia 40 50000
003 Gautham 29 54000
004 Arifa 30 25000
;
Run;
Proc print data=Informat01;
Run;

In this list-input example, the dollar sign after Name defines it as a character variable. The following example uses an explicit character informat so that a name can contain an embedded blank:

</>
Copy
data employees;
    input id name & $20. age;
datalines;
101 David Kumar  29
102 Amelia Roy  40
;
run;

Numeric Informats for Commas, Currency, and Percentages

Numeric informats convert numeric-looking text into SAS numeric values. They are needed when the source field contains punctuation or symbols that ordinary numeric input does not handle as intended.

Raw valueSuitable informatStored numeric value
12,500COMMA6.12500
$7,500DOLLAR6.7500
18.5%PERCENT5.0.185
1.25E3E32.1250

Numeric COMMA Informat Example Program

Data Informat2;
Infile datalines;
input Idnumber Name$ age sex$ Sal comma6.;
Datalines;
0001 David 30 M 10,0000
0002 Virat 35 M 90,0000
0003 Diya 29 F 30,000
0004 Devilliers 38 M 60,000
0005 Ravi 40 M 75,000
Run;
Proc print data=informat2;
Run;

The example demonstrates the purpose of the COMMAw.d informat: it removes commas while converting a field to a numeric value. In actual input data, the informat width must be large enough for the complete field, including commas, a sign, and any decimal point. The data must also include the semicolon that ends the DATALINES section.

The same principle applies to currency values:

Data Informat3;
Infile datalines;
input Idnumber Name$ age sex$ Sal dollar5.;
Datalines;
0001 David 30 M $10000
0002 Virat 35 M $90000
0003 Diya 29 F $3000
0004 Devilliers 38 M $6000
0005 Ravi 40 M $7500
Run;
Proc print data=informat3;
Run;

When using DOLLARw.d, count the dollar sign, commas, decimal point, and digits when selecting the width. For example, $90,000 requires a width of at least 7.

</>
Copy
data salaries;
    input employee_id name $ salary :dollar10.;
datalines;
0001 David $10,000
0002 Virat $90,000
0003 Diya $30,000
;
run;

SAS Date, Time, and Datetime Informats

Date and time informats convert readable text into SAS numeric values. A SAS date is stored as the number of days from January 1, 1960. A SAS time is stored as the number of seconds since midnight, and a SAS datetime is stored as the number of seconds from midnight on January 1, 1960.

DateSAS date value
January 1, 19600
January 5, 19604
December 31, 1959-1
June 18, 200616,970

After SAS reads a date or time value, assign a corresponding format to make the stored number readable in reports and output data sets.

Choosing a SAS Date Informat

The width in a date informat should accommodate the complete source field. For example, MMDDYY10. reads a ten-character value such as 07/17/2026. When a column contains several recognizable date styles, ANYDTDTEw. can read many common date representations. A specific informat is preferable when the source layout is known because it makes the expected date order explicit.

Source valueSuitable informatMeaning
29JAN10DATE7.29 January 2010
29JAN2010DATE9.29 January 2010
29/01/10DDMMYY8.29 January 2010
29/01/2010DDMMYY10.29 January 2010
01/29/2010MMDDYY10.29 January 2010
18:45:30TIME8.6:45:30 PM
29JAN2010:18:45:30DATETIME18.A SAS datetime value

WORDDATEw. is generally used as an output format, not as the usual informat for reading a value such as January 29, 2010. For mixed date text, consider ANYDTDTEw. and verify ambiguous day-month ordering before processing the data.

Date and Time Informat Example Program

Data Informat4;
Infile datalines;
input Idnumber Name$ age sex$ Sal dob date9. doj:ddmmyy10.;
/*input Idnumber Name$ age sex$ Sal dob anydate9. doj:ddmmyy10.;*/
Datalines;
0001 David 30 M 10000 10Feb1983 12/02/2011
0002 Virat 35 M 90000 18Jun2006 15/01/2011
0003 Diya 29 F 3000 14Jun1988 31/01/2011
0004 Devilliers 38 M 6000 13Feb1980 25/02/2011
0005 Ravi 40 M 7500 10Aug1981 08/03/2011
Run;
Proc print data=informat4;
Run;

The colon before DDMMYY10. is an informat modifier used with list input. The program reads both date fields as numeric SAS dates. Add formats when you want the printed output to show readable dates rather than their internal day counts:

</>
Copy
format dob date9. doj ddmmyy10.;

Column-Binary Informats in SAS

Column-binary informats read values stored in column-binary or multi-punched representations. They apply to specialized external data layouts and are uncommon in ordinary delimited text files. Examples include informats from the column-binary family such as ROWw.d and character column-binary informats. Select one only when the source system documentation identifies the corresponding binary encoding.

User-Defined SAS Informats with PROC FORMAT

A user-defined informat maps source text or ranges to values chosen by the programmer. Create it with PROC FORMAT and an INVALUE statement. Character informat names begin with a dollar sign; numeric informat names do not.

</>
Copy
proc format;
    invalue yesno
        'Y', 'YES' = 1
        'N', 'NO'  = 0
        other      = .;
run;

data responses;
    input customer_id accepted :yesno.;
datalines;
101 YES
102 N
103 Y
104 UNKNOWN
;
run;

In this example, YESNO. converts recognized yes/no text to 1 or 0 and assigns a missing numeric value to other input. User-defined informats are useful for controlled codes, legacy labels, and recurring source-system conventions.

Common SAS Informat Errors and Fixes

ProblemLikely causeCorrection
A numeric value becomes missingThe raw text does not match the selected informatInspect the original value and use an informat designed for that pattern
A value is truncated or read incorrectlyThe informat width is too smallCount every digit, separator, sign, and currency symbol when choosing the width
A date is stored as an unexpected dayDay-month and month-day orders were confusedUse DDMMYYw. or MMDDYYw. explicitly
A date prints as a numberThe value was read correctly but has no date formatAssign a format such as DATE9. or DDMMYY10.
The SAS log reports invalid dataThe field contains unhandled text, blanks, or symbolsReview the log note, inspect representative records, and choose or create a matching informat

SAS Informat Validation Checklist

  • Confirm whether the destination variable must be character or numeric.
  • Compare the informat with the exact punctuation and ordering in the source values.
  • Make the informat width large enough for the longest valid input field.
  • Check ambiguous dates with known records before processing the full file.
  • Apply a format separately when stored dates, times, or numeric values need readable output.
  • Review the SAS log for invalid-data notes and unexpected automatic conversions.
  • Test missing values, unexpected codes, and boundary-length fields when using a user-defined informat.

SAS Informat Frequently Asked Questions

What does an informat do in SAS?

An informat tells SAS how to convert raw input text or binary data into a SAS character or numeric value. Examples include converting $12,500 to a number or converting 17/07/2026 to a SAS date.

What is the difference between an informat and a format in SAS?

An informat is used while reading data. A format controls how an already stored value is displayed. A SAS date informat converts date text to a day count, while a date format displays that count as a readable date.

When should the INFORMAT statement be used?

Use the INFORMAT statement when a variable should retain an informat association for subsequent input operations in the DATA step. If an informat is needed only for one field in one INPUT statement, it can be written directly in that statement.

Why does a SAS date display as a number?

SAS stores a date as a numeric day count from January 1, 1960. If the date was read successfully but prints as a number, assign a date format such as DATE9., DDMMYY10., or MMDDYY10..

Can a custom informat be created in SAS?

Yes. Use PROC FORMAT with an INVALUE statement to create a user-defined informat that converts source codes, labels, or ranges into standardized SAS values.