## SAS informat with decimal

Solved
Frequent Contributor
Posts: 82

# SAS informat with decimal

In this paper:

http://support.sas.com/publishing/pubcat/chaps/59498.pdf

This pharagraph:

Line 3 uses the numeric informat 8.2. The w.d informat provides instruction to read

the numeric data having a total width of 8 (8 columns) with two digits to the right of

the decimal point. SAS will insert a decimal point only if it does not encounter a

decimal point in the specified w columns. Therefore, we could have coded the

informat as 8. or 8.2.

How come 8. and 8.2 are the same? 8. will truncate the decimal portion of the input, correct?

Accepted Solutions
Solution
‎07-30-2014 04:46 PM
Super User
Posts: 5,496

## Re: SAS informat with decimal

Informats 8. and 8.2 give the same result whenever the incoming data already contains a decimal point.  They produce different results when the incoming data contains no decimal point.

As an informat, 8. will not truncate anything.  It reads 8 characters and takes whatever it finds as the value.  It respects decimal points.

As an informat, 8.2 reads the same 8 characters.  If they contain a decimal point, the result is the same as using the 8. informat.  However, if there is no decimal point, 8.2 assumes that the list 2 digits read should fall after the decimal point.

As formats instead of informats, the process is different.  That's another question for another day, but it might be related to your assumption that 8. will truncate.

All Replies
Posts: 1,228

## Re: SAS informat with decimal

Informat 8.2 has width of 8, 5 digits before decimal one for decimal and remaining two after decimal.

data have;
input num 8.2;
datalines;
29453.83
23.3
;

data have;
input num 8.;
datalines;
29453.83
23.3
;

Frequent Contributor
Posts: 82

## Re: SAS informat with decimal

I know that "Informat 8.2 has width of 8, 5 digits before decimal one for decimal and remaining two after decimal"...but question is different..how come 8. and 8.2 are same as suggested by the article?

Solution
‎07-30-2014 04:46 PM
Super User
Posts: 5,496

## Re: SAS informat with decimal

Informats 8. and 8.2 give the same result whenever the incoming data already contains a decimal point.  They produce different results when the incoming data contains no decimal point.

As an informat, 8. will not truncate anything.  It reads 8 characters and takes whatever it finds as the value.  It respects decimal points.

As an informat, 8.2 reads the same 8 characters.  If they contain a decimal point, the result is the same as using the 8. informat.  However, if there is no decimal point, 8.2 assumes that the list 2 digits read should fall after the decimal point.

As formats instead of informats, the process is different.  That's another question for another day, but it might be related to your assumption that 8. will truncate.

🔒 This topic is solved and locked.