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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

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