DATA Step, Macro, Functions and more

Convert Exponential value to numeric value in SAS

Reply
Contributor
Posts: 71

Convert Exponential value to numeric value in SAS


Hi SAS Experts,

I tried the following solution but the problem I discovered is that numbers who arent exponential are converted to something strange as well.
One of the problems might be that my source column/variable is actually of format "number" and the example creates values in format character.

http://stackoverflow.com/questions/19678279/sas-programming-convert-exponential-value-to-numeric-val...

data test;  
  a='3.24456545e-3'; output;  
  a='3.22254e2'; output;  
  a='9.151451'; output;  
  a='0.151451'; output;
run;  

data erg;  
  set test;  
  b=input(a,32.16);  
run; 

Are there other ways how to deal with exponentials that are of format "number" ?

Super User
Posts: 10,483

Re: Convert Exponential value to numeric value in SAS

You don't mention what you may have read to text values but try something like:


data erg;  
  set test;  
  b=input(a,best32.);  
run; 

Assign a display format you like.

 

Super User
Posts: 5,081

Re: Convert Exponential value to numeric value in SAS

Why do you say there is any issue at all?  What results do you see when you add this statement to the final DATA step:

 

put a= b=;

Super User
Posts: 9,673

Re: Convert Exponential value to numeric value in SAS

data test;  
  a='3.24456545e-3'; output;  
  a='3.22254e2'; output;  
  a='9.151451'; output;  
  a='0.151451'; output;
run;  

data erg;  
  set test;  
  b=input(a,e32.);  
run; 
Ask a Question
Discussion stats
  • 3 replies
  • 862 views
  • 2 likes
  • 4 in conversation