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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

3 REPLIES 3
ballardw
Super User

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.

dr2014
Quartz | Level 8

Thanks for your reply @ballardw. I got the generated data step and will fix the length of the variables.

ballardw
Super User

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5394 views
  • 0 likes
  • 2 in conversation