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

Capture.PNG

 

I have a column called 'bp' whose type is 9~10 digits integers. However, it shows only upto 8th digit. Appreciate if you could let me know what is the problem.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You set the INFORMAT to read 8 characters, but you are NOT using that for anything in your code.

But in your INPUT() function call you also told it to only read 8 characters.  Change that to use more characters.  Go ahead and use 32 as that it max that the informat supports.

bp = input(....., ??32.);

You also might want to add a FORMAT statement to tell SAS how to display the value, although normally SAS will use BEST12. as the default and that should easily display 10 digit integers.

 

In the last data step you set the length of BP to 8 bytes (why you included a period in the LENGTH statement I don't know because2 lengths are always integer values).  That shouldn't change the value as SAS always processes numbers using 8 byte floating point format.  And if you did previous use a shorter length when create the data you are reading in that step the extra precision is lost so increasing it back to the normal 8 cannot find the missing bits of precision.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

You set the INFORMAT to read 8 characters, but you are NOT using that for anything in your code.

But in your INPUT() function call you also told it to only read 8 characters.  Change that to use more characters.  Go ahead and use 32 as that it max that the informat supports.

bp = input(....., ??32.);

You also might want to add a FORMAT statement to tell SAS how to display the value, although normally SAS will use BEST12. as the default and that should easily display 10 digit integers.

 

In the last data step you set the length of BP to 8 bytes (why you included a period in the LENGTH statement I don't know because2 lengths are always integer values).  That shouldn't change the value as SAS always processes numbers using 8 byte floating point format.  And if you did previous use a shorter length when create the data you are reading in that step the extra precision is lost so increasing it back to the normal 8 cannot find the missing bits of precision.

ChrisNZ
Tourmaline | Level 20

Also, 

length BP 8.;

is not valid syntax,

 

You are mixing format and length syntax.

You should have:

length BP 8;

 

Do not mix what variable length and format are. Especially for numeric variables.

 

Numeric variables should always have a length of 8 bytes, unless you have a good reason to change this, and you know about the dramatic consequences a different value can have.

 

 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2995 views
  • 2 likes
  • 3 in conversation