Hi all,
I imported a text tab delimited file into SAS 9.4 and the all the numeric fields are converted into an exponent of 10. So for e.g how do I convert 5.8432957E13 into the actual number 58432957310473 in the sas file now? The value with the exponent E is a numeric field with a best12. format and informat.
Thanks in advance for your solutions.
Run proc contents on your data. I suspect that what happened is that the default format of BEST12 was applied to a value that was longer than 12 digits. So SAS uses exponential notation to make it fit.
Then go back a verify that the value involved should actually be numeric. If the variable represents something like an account number or other ID then it should not be numeric at all. Especially if some original values may have exceeded 15 characters.
I would suggest that if you used Proc Import to read the data that you do so again but afterward
1) go to the log
2) copy the generated data step code to the editor
3) modify any informat/format statements to make sure that the variables are read as the correct type and with an appropriate length.
4) Save the code
Then when you need to read another similar file you just change the infile to point to the new source and change the output data set name. Then if you need to combine the two sets you will not have issues with variables of different types or lengths causing problems or errors.
Run proc contents on your data. I suspect that what happened is that the default format of BEST12 was applied to a value that was longer than 12 digits. So SAS uses exponential notation to make it fit.
Then go back a verify that the value involved should actually be numeric. If the variable represents something like an account number or other ID then it should not be numeric at all. Especially if some original values may have exceeded 15 characters.
I would suggest that if you used Proc Import to read the data that you do so again but afterward
1) go to the log
2) copy the generated data step code to the editor
3) modify any informat/format statements to make sure that the variables are read as the correct type and with an appropriate length.
4) Save the code
Then when you need to read another similar file you just change the infile to point to the new source and change the output data set name. Then if you need to combine the two sets you will not have issues with variables of different types or lengths causing problems or errors.
Thanks for your reply @ballardw. I got the generated data step and will fix the length of the variables.
If the value(s) are id or similar you likely want to change those to character. Simple with the data step replace the (likely ) infromat from BEST32. to $15. or similar to set a character length of 15 characters.
Typically I will set the length for ID variables to 1, 2 or 3 characters more than the longest I receive in the file. And things like names or other text add about 10 to 15% to allow for some slightly longer values in later files.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: