- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi SAS Community,
You've got a newbie in the building when it comes to SQL, so please be gentle as to date I have been using EG in anything I've been carrying out. I've been told that I have a really simple piece of existing code that can just be ran without issue, but it's throwing up an error on step 1.
Error "Expression using equals (=) has components that are of different data types"
I've determined that the code is trying to pull in a numerical value against a left join that has a character value but I don't know how to write the code to change the numerical to character apart from thinking it needs to read something like gl_codes=put(account,8)
from INPUT_DATA as t1
left join gl_codes as t3
on t1.account =t3.gl_code
gl_codes is numeric
account is character (LENGTH8)
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Something like this:
on t1.account = put(t3.gl_code,8.)
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Follow Maxim 3 and get to know your data:
How many digits are stored in account? Are there leading zeroes? Are the values left- or right-aligned?
This will determine how you do the conversion of the numeric variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Very likely, it would be simpler to (for comparison purposes) convert from character to numeric:
from INPUT_DATA as t1
left join gl_codes as t3
on input(t1.account, 12.) = t3.gl_code
Just pick a wide enough width ... this example assumes that ACCOUNT will be no longer than 12 characters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If your goal is to convert a numeric variable to a character variable you must use the "PUT" function.
The PUT function is as follows:
new_variable = PUT (original_variable, format.);
If your goal is to convert a character variable to a numeric variable, you must then use the "INPUT" function,
The INPUT function is as follows:
new_variable = INPUT (original_variable, informat.);
I hope these two functions help with your future conversions of variables.
De'Janae'