DATA Step, Macro, Functions and more

informat about how many decimal place to be read?

Reply
N/A
Posts: 0

informat about how many decimal place to be read?

As far as my knowledge is concerned, when a informat, such as w.d or COMMAw.d, is used in a input statement. The number of decimal place to be read is depended on the digit d I specified in the informat. However, while I submit the following SAS code, the output are rounded off to the 3rd decimal place rahter than the 2nd decimal place. Is my understanding about the informat wrong? Can anyone help me to explain the output? Thanks for your kindness and enthusiasm.



data a;
input x 6.2;
cards;
123.45
65
3.11
9.025
0.3983
;
proc print; run;


The output is

Obs x

1 123.450
2 0.650
3 3.110
4 9.025
5 0.398
Super User
Posts: 10,018

Re: informat about how many decimal place to be read?

Posted in reply to deleted_user
Hi . you need a format to print it.

[pre]



[/pre]




data a;



input x 6.2;



format x 6.2;



cards;



123.45



65



3.11



9.025



0.3983



;



proc print; run;




[pre]



[/pre]



Ksharp
Regular Contributor
Posts: 151

Re: informat about how many decimal place to be read?

Posted in reply to deleted_user
You should not use decimals in your informat.

Input x 6.;

With decimals value 65 is read as 0.65 Message was edited by: Oleg_L
N/A
Posts: 0

Re: informat about how many decimal place to be read?

This is a fictitious data. I use it just want to demonstrate how the informat will influent different kinds of input data. Especially when the informat does not conform to the format of input data, the incompatible informat will effect the data SAS system actually read in. Hence the value 65 is read as 0.65 is just what I want to get. However, I encounter the unexpected problem aforementioned.
Valued Guide
Posts: 2,177

Re: informat about how many decimal place to be read?

Posted in reply to deleted_user
I think if you read the manual you'll find that your informat's ".2" will only be used when no decimal point is present in the raw source string.
Ask a Question
Discussion stats
  • 4 replies
  • 141 views
  • 0 likes
  • 4 in conversation