turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Data Mining
- /
- SAS informat with decimal

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-30-2014 03:46 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to eagles_dare13

07-30-2014 04:46 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to eagles_dare13

07-30-2014 04:39 PM

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

;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stat_sas

07-30-2014 04:45 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to eagles_dare13

07-30-2014 04:46 PM

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.