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

Hi there everyone,

 

I'm still new to the sas world and currently stuck trying to format a variable. 

 

I have a proc sql step and I'm hitting a sequel table but the column I'm matching it with is not numeric. I'm wanting to format b.AccountNumber; to numeric  but not sure what steps to take.

 

see below 

 

proc sql; create table FTY1 as select
a. *
,b. ResponseCodeMessage


from FTY a left outer join COL.biz b on a.Account_number=b.AccountNumber;
quit;

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

I assume that b.AccountNumber is the one that is not numeric?

 

proc sql; create table FTY1 as select
a. *
,b. ResponseCodeMessage
from FTY a left outer join COL.biz b on a.Account_number=input(b.AccountNumber, best.);
quit;

View solution in original post

10 REPLIES 10
PeterClemmensen
Tourmaline | Level 20

I assume that b.AccountNumber is the one that is not numeric?

 

proc sql; create table FTY1 as select
a. *
,b. ResponseCodeMessage
from FTY a left outer join COL.biz b on a.Account_number=input(b.AccountNumber, best.);
quit;
Ela_84
Fluorite | Level 6

that's correct - Thank you SOOOO much.

I will give it a try and let you know if it works.

 

Appreciate this alot.

Ela_84
Fluorite | Level 6

Thank you so much Draycut - it worked appreciate the help again.

 

Have an awesome day!

rajeshm
Quartz | Level 8

Thanks for the answer ,useful to me.

q1:  one col is  numeric and one col is char. when comparing which is best ? char to numeric conversion or numeric to char ? please give some explanation,please.

TomKari
Onyx | Level 15

It depends...

 

Don't you love that answer? But seriously, it does, and here are some of the considerations.

 

If you're SURE that your character column always contains number, and you can reliably convert them to numeric, then I would go with numeric, as it's not subject to odd formatting issues (does '5 ' equal '5'? does ' 5' equal '5'?)

 

If you're going to have issues (e.g. converting 'abc' to numeric), then you might want to go with character. It may be challenging to figure out how to convert your numeric value to character, SAS has lots of functions to help. (There's the subject for your next question!)

 

In either case, be cautious about numbers with fractions. They don't always convert nicely to the hexadecimal used by computers, and two numbers that look similar can actually be different.

 

My two cents worth!

   Tom

rajeshm
Quartz | Level 8

thanks for reply.

I did not get answer for my question.

we can convert from numeric to character (or vice versa) 

My intention is to know  which conversion should be happened to get better performance?

(char to numer or numer to char)??

 

 

PaigeMiller
Diamond | Level 26

@rajeshm wrote:

 

we can convert from numeric to character (or vice versa) 

My intention is to know  which conversion should be happened to get better performance?

(char to numer or numer to char)??


What do you mean by "performance"?

--
Paige Miller
rajeshm
Quartz | Level 8
several ways to find a solution to a problem.
suppose i have a case to compare numeric with char.
if i convert character to numeric and comparing with numeric will be executed in less time ? or
if i convert numeric to character and comparing with character will be executed in less time?
PaigeMiller
Diamond | Level 26

I don't know, buy you can find the answer easily enough.

 

Create data sets where the variable of interest is numeric and a similar data set where the variable of interest is character.

 

Then compare by converting to character to numeric. Then compare by converting numeric to character. Which one runs faster?

--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 10 replies
  • 12680 views
  • 1 like
  • 5 in conversation