BookmarkSubscribeRSS Feed
Alexxxxxxx
Pyrite | Level 9

Hi,

 

I am trying to import the excel file into SAS, the value in excel is '0.015162' become '1.5162E-2' in the SAS.

 

Do you know what should I do if I want to keep the value in Excel (0.015162) does not change when import into SAS?

or how to transfer the value  '1.5162E-2' in SAS into '0.015162'?

 

Thanks in advance.

3 REPLIES 3
SASKiwi
PROC Star

Try applying a format to the variable like 12.6. 

ballardw
Super User

Likely all you need to do is change a format. Maybe.

 

The values SAS stores always have some sort of format associated. If something about the value does not fit the current format than SAS will try its best to display it in some meaningful format. So the value is the same despite what the appearance may be (barring numeric precision issues)

 

You can run the following code and look in the Log for the results. Same value but different formats.

data example;
  x = 0.015162;
  put "Using best5. format: " x= best5.;
  put "Using best8. format: " x= best8.;
  put "Using E12. format: " x= E12.;
run;

Since you mention EXCEL I am going to guess that some of the values in the same column are quite a bit larger than 0.01516, perhaps with 10 or more digits before a decimal. Those values were used to set a format that displays with fewer characters.

 

I suspect that if assign a format like BEST12 or so you might see more what you expect. That can be done in a new dataset, use proc datasets to set the format, or possibly even just click on a table column heading ins SAS and bring up a properties window where you can change the format.

 

NOTE: Repeat, regardless of what you SEE SAS formats do not change values. Period.

Tom
Super User Tom
Super User

@Alexxxxxxx wrote:

Hi,

 

I am trying to import the excel file into SAS, the value in excel is '0.015162' become '1.5162E-2' in the SAS.

 

Do you know what should I do if I want to keep the value in Excel (0.015162) does not change when import into SAS?

or how to transfer the value  '1.5162E-2' in SAS into '0.015162'?

 

Thanks in advance.


What is the issue here?  Those two strings you showed seem to represent the same number.

If you want to change how the number is displayed use a different format.

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
  • 3 replies
  • 813 views
  • 0 likes
  • 4 in conversation