BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
djbateman
Lapis Lazuli | Level 10

I have a situation where we are storing the protocol version on which a subject is enrolled, and we noticed that SAS is truncating trailing zeros.  For example, there are at least 10 subversions of a protocol, so one subject was enrolled on version 8.1 while another was enrolled on version 8.10.  When SAS brings in this data, it  understandably converts 8.10 to 8.1, but they aren't the same value.  Is there a format that could be applied to retain this?  I have a feeling that the only solution is to store the protocol version as a character string, but before I have our database designer revamp things (if even possible at this point), I wanted to see if there was an alternative function or format in SAS.  I can't imagine that SAS can tell the difference between "8.1" and "8.10" anyway because decimal precision would treat them the same with or without that zero.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

If these are versions and not numbers, make them character, and then the problem is solved.

 

If these are numbers, SAS will always treat 8.1 and 8.10 as the same number.

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

If these are versions and not numbers, make them character, and then the problem is solved.

 

If these are numbers, SAS will always treat 8.1 and 8.10 as the same number.

--
Paige Miller
djbateman
Lapis Lazuli | Level 10
That's what I figured. I'll let them know that the variable has to be character from the start. Thanks for confirming!
FreelanceReinh
Jade | Level 19

Another option might be to use leading zeros for subversions <10, i.e., 8.01, 8.02, etc., and then to use a format such as 6.2 to display 8.1 as 8.10.

 

Using a character variable is still the more robust solution, though. I have seen numeric non-integer values with a similar purpose in a clinical database which surprisingly were affected by tiny rounding errors (or numeric representation errors from the external database) so that testing exact equality (as in "if version=8.01 then ...") failed.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 589 views
  • 0 likes
  • 3 in conversation
OSZAR »