- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If your character accountid does have more than 15 digits, you must not do that, as you will lose precision in the conversion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.