BookmarkSubscribeRSS Feed
shuchidxt_gmail_com
Obsidian | Level 7

Hi,

 

I need to convert 25 length of character variable to numeric field in SAS.

 

Example :

I have field XYZ having data ='27201807000526_61135239'.

 

I want to create another NUMERIC variable ABC = 27201807000526_61135239'.

 

Is this possible? Since the length of the numeric is grater than 16.

7 REPLIES 7
ChrisBrooks
Ammonite | Level 13

An underscore isn't a numeric character so you won't get exactly what you seem to want. If you can explain why you need to convert this value to numeric might be able to offer an alternative strategy.

shuchidxt_gmail_com
Obsidian | Level 7

I don't know how the data is being used. We sent the data to downstream application for their usage.

Tom
Super User Tom
Super User

@shuchidxt_gmail_com wrote:

I don't know how the data is being used. We sent the data to downstream application for their usage.


HOW do you send it?

ChrisNZ
Tourmaline | Level 20

SAS can store no more than 16 digits accurately, under certain conditions.

Integer numbers greater than 2**53 can get distorted.

For decimal numbers, the number of exact digits is 15 maximum.

 

These are for PC/Unix. Mainframes are more accurate (but store smaller exponent sizes).

 

Astounding
PROC Star

You can't convert it to numeric, since it isn't a number.  If I said I was going to give you 27201807000526_61135239 chicken feathers, how many chicken feathers is that?

shuchidxt_gmail_com
Obsidian | Level 7

Yes, I know that we cannot change it to numeric. I want to get assured that there is no way to convert it to numeric.

 

 

Kurt_Bremser
Super User

27201807000526_61135239 is not a number, therefore your question does not make sense. If you need to convert a part of this string to a number, then it's different, but you would need to tell us so.

If the underline is in fact the decimal point (or similar), the number would have too many digits for SAS and you would lose precision.

You could convert this string reliably to two separate numbers, OTOH.

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!

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
  • 7 replies
  • 874 views
  • 2 likes
  • 6 in conversation