BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
4 REPLIES 4
Ksharp
Super 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
Oleg_L
Obsidian | Level 7
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
deleted_user
Not applicable
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.
Peter_C
Rhodochrosite | Level 12
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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 983 views
  • 0 likes
  • 4 in conversation