- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I need to convert a character variable into a numeric variable, by means of an expression in an Extract transformation.
The character variable is called Cust_No, and has the format $8. It needs to become a numeric variable with the format 8.0.
How can I accomplish this? I'm going insane experimenting with PUT, PUTC, PUTN, INPUT, INPUTN, INPUTC, etc. Whenever I think I've done it, the SQL Join tells me that I have the wrong data type.
I thought it would be correct to use this: input(Cust_No, 8.) However, that just turns all the values blank.
Thanks. ![]()
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Have you tried this:
data temp;
set your_data;
new_Cust_no = Cust_no * 1;
run;
Good luck!
Anca.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. For some reason, when I do either of those things, the variable becomes blank, as though it refuses to be numeric.
Out of curiosity, should I be able to do an inner join on character variables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you should be able to do inner join on character variables.
Would you, please, share the code?
And a small sample data?
How about
new_var = input(old_var,best.);
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You are on the right path. input() will convert the character variable into numeric. it should work.
try this
x=input(Cust_No, 8.);
so are you trying that in sql, could you please send me the code you have used in sql.
Thanks,
Jagadish
Jag
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sounds like your character variable is either blank or is longer than 8 characters and is right aligned so that the first 8 positions are blank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Resolved it using characters instead. Thanks for your advise though, I learned something. ![]()