Hi Forum,
I'm using SAS Enterprise Guide 4.3 with Windows 7 in case it's useful.
I have 2 tables, with a Month_Id written as '201310' to denote October 2013 for example.
Problem is, I have one table with this Column created as an Integer & another as a Varchar.
What is the best way to change one of them to the others datatype so I can join them?
Thanks
The EG Query Builder is a wizard which generates SQL code. As with all wizards there are always limitations.
What proposes would work but I haven't found a way using the wizard to generate such code.
If you need an inner join (so the result only containing matching rows) then you could "trick" the wizard by not defining a join at all but by defining a filter (this results in an implicit inner join).
I'm using an expression 'input(character_key, best16.)' which converts the digits in the character variable into a numeric value before comparing with the numeric key.
If you need another sort of join (eg. a left join) then I believe you need first a query builder node to create a calculated field which contains this numeric value (so you're using the input() there) and then you use the output table of this query in the next query builder where you join the 2 tables together.
Join on put(integervaluedvariable, f6.) = characterversion
Hi ballardw,
Thanks for the response but I don't know what you mean?
Could you explain it in terms of using a Query builder with 2 tables, one table 'Table1' with the field 'Mon_Yr' as an Integer datatype & another table 'Table2' with the field 'Mon_Yr' as a Varchar datatype?
Thanks
The EG Query Builder is a wizard which generates SQL code. As with all wizards there are always limitations.
What proposes would work but I haven't found a way using the wizard to generate such code.
If you need an inner join (so the result only containing matching rows) then you could "trick" the wizard by not defining a join at all but by defining a filter (this results in an implicit inner join).
I'm using an expression 'input(character_key, best16.)' which converts the digits in the character variable into a numeric value before comparing with the numeric key.
If you need another sort of join (eg. a left join) then I believe you need first a query builder node to create a calculated field which contains this numeric value (so you're using the input() there) and then you use the output table of this query in the next query builder where you join the 2 tables together.
Thanks ballardw/Patrick,
I'll give these a try. :smileycool:
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.