BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
eagles_dare13
Obsidian | Level 7

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.

View solution in original post

3 REPLIES 3
stat_sas
Ammonite | Level 13

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
;

eagles_dare13
Obsidian | Level 7

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?

Astounding
PROC Star

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 14566 views
  • 1 like
  • 3 in conversation