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.
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.
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.
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.
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.
Ready to level-up your skills? Choose your own adventure.