BookmarkSubscribeRSS Feed
nickspencer
Obsidian | Level 7
Hi,
I am trying to convert a character variable to numeric but when I use input function it is returning me the numeric value in scientific notation. Is there a way I can get a proper value ?
I am using the input function as below
acct_id=input(accountid, 20.);

I tried the best32. informat. It still returns in the same format with scientific notation like 4.9975044E14
The original format/informat of the accountid shows $15.

Any help that will help me get the proper value will be appreciated. Thanks
6 REPLIES 6
Astounding
PROC Star

You're getting the right value originally.

 

The problem is with formatting.  Add:

 

format acct_id 15.;

 

That should display ACCT_ID without scientific notation (assuming, as you say, that values are limited to 15 digits).

PaigeMiller
Diamond | Level 26

I don't see any possible reason why you'd want to convert ACCT_ID to a number anyway. You don't need it to be numeric, there's no such thing as performing arithmetic on an ACCT_ID, for example, to find the average ACCT_ID.

--
Paige Miller
ballardw
Super User

@nickspencer wrote:
Hi,
I am trying to convert a character variable to numeric but when I use input function it is returning me the numeric value in scientific notation. Is there a way I can get a proper value ?
I am using the input function as below
acct_id=input(accountid, 20.);

I tried the best32. informat. It still returns in the same format with scientific notation like 4.9975044E14
The original format/informat of the accountid shows $15.

Any help that will help me get the proper value will be appreciated. Thanks

Please tell us what you expect to do with a numeric version of the account id that you cannot do with a character version.

Please.

nickspencer
Obsidian | Level 7
I am trying to load this data into a teradata table but for some reason it has the column as numeric
Kurt_Bremser
Super User

Maybe for space reasons. DB systems usually use 8 bytes for numbers, like SAS, so you save can 7 bytes.

As long as you can be sure that you never have more than 15 digits, you can store that reliably as a number.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2696 views
  • 0 likes
  • 5 in conversation