BookmarkSubscribeRSS Feed
aziq_az1304
Calcite | Level 5

Hi, I'm still new to sas programming. My question as per example below :-

 

In excel : 1.322E+22

 

Need to change into this format : 1322000246674 (string)

 

Anyone can help me on this. I've tried change the format into string somehow it is still the same.

I've tried used functionPUT/INPUT but still the same.

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Do you want to do this in Excel or in SAS?

 

I don't think you can convert a number with E+22 exactly

--
Paige Miller
Rick_SAS
SAS Super FREQ

Were you able to successfully read the data from Excel into a numeric variable in a SAS data set? That is the first step.

 

The second step is to use the PUT statement and specify a format that is suitable for your purpose. In the following program, I show how to use the w.d format 30.16, but you might prefer to use 30. if the number is always an integer.

/* Assume that you have read the data into a SAS data set named "Have".
  Here, I create the data set with fake data. */
data Have;
input x;
datalines;
1.322E+22
1.23456789E16
;

data Want;
length str $30;
set Have;
str = put(x, 30.16);  /* apply a SAS format to convert the number to a string */
run;

proc print; run;

For more information, see "Convert numeric values to character."

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 715 views
  • 0 likes
  • 3 in conversation