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-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!

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
  • 552 views
  • 0 likes
  • 3 in conversation