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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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