BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8
If i special format as 17.2 on input statement, can sas read in a different format say 17.4?

I know if i dont specify it reads in any number
3 REPLIES 3
PaigeMiller
Diamond | Level 26

You could try it and find out yourself. Maxim 4

--
Paige Miller
yabwon
Onyx | Level 15

Do as @PaigeMiller said, but also test those 2 examples:

data test1;
 input x 17.2;
cards;
17.1
17.22
17.333
17.4444
17.55555
;
run;
proc print;
run;

data test2;
 input x 17.2;
cards;
171
1722
17333
174444
1755555
;
run;
proc print;
run;

and also see the doc:

w.d Informat :: SAS(R) 9.4 Formats and Informats: Reference

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Tom
Super User Tom
Super User

@HeatherNewton wrote:
If i special format as 17.2 on input statement, can sas read in a different format say 17.4?

I know if i dont specify it reads in any number

You cannot use any FORMAT with an INPUT statement.  You can only use an INFORMAT.

 

Normally you never want to include a decimal place value on an informat because that means that SAS will insert an implied decimal point when the string does not have one.

 

The difference between 17.2 and 17.4 is where SAS will place the decimal point when the string does no contain one.

With 2 implied decimal places a string like '123456' will become the number 1234.56 but with 4 implied decimal places it will become 12.3456 instead.

 

So the proper informat to use when the values are 17 bytes long and did not have the decimal point purposely removed would be 17. with no number after the period.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 490 views
  • 5 likes
  • 4 in conversation