BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Patrick
Opal | Level 21

Do the join where your data lives - so do it in Oracle. I was thinking that it shouldn't be too hard to convert character to numeric (or the other way round) in Oracle using either TO_NUMBER() or TO_CHARACTER.

Being an iregular Oracle user I Googled the doc to post the correct syntax - and then look what I found under Datatype Comparison Rules

"When comparing a character value with a numeric value, Oracle converts the character data to a numeric value."

Capture.PNG

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

is it possible to add leading "0"s to a numeric variable in SAS and still have it as numeric?

ballardw
Super User

The interal storage of numbers doesn't change but for any time you want to SEE leading zeroes use the Zw.d format.


Reid
Fluorite | Level 6

i think so , i will defiantly post  it. If i come up with come up some  thing...

Ksharp
Super User

So my A is still numeric variable.

but its internal  value is 374747830939 , it looks like  000374747830939 .

Tom
Super User Tom
Super User

You can add as many leading zeros to a number as you want and it will not change the value.

0 x 10**100 is still 0.

Tom
Super User Tom
Super User

You cannot add leading zeros to a number.  It just does not make sense either mathematical or in computer science.

What is your actual problem?  Are you having trouble querying the data?  Or matching records between two tables (datasets) ?

Can you show the example data?

With SAS you can add a format to display a number with leading zeros.  You can even have the format permanently attached to the variable in the definition of the dataset so that the default for displaying the number will include the leading zeros.  I do not think you can do the same in Oracle.  You can use a function call to convert a number to a character string and specify that leading zeros are printed.  Is that what you want to know how to do?  To do that in Oracle use to TO_CHAR function with a format.

Example:

to_char(12.349,'099999.99') returns "000012.35"

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 21 replies
  • 217442 views
  • 10 likes
  • 8 in conversation