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!
Something like this:
on t1.account = put(t3.gl_code,8.)
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.
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.