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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 2685 views
  • 2 likes
  • 3 in conversation