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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.