I have a sql query which I am trying to convert to sas eg's visual interface. The query uses an inner join between the two tables, but the column on which I'm joining from table 1 is a computed column. The from statement looks like this:
FROM table1 t1 INNER JOIN table2 t2 ON (year (table1.calldate) = table2.year)
I could not find a way to do this in one visual query in EG. Computed columns don't show up in the joins dialog box, and the filter section of the joins dialog box seems to be that.... a filter, not a way to create a new column.
Is there a way to do his, or does EG require that table 1 is pre-querying to create the year(table1.calldate) field.
Any advice would be much appreciated.
Thanks
A work-around is to use a implicit SQL join:
FROM table1 t1, table2 t2 WHERE (year (t1.calldate) = t2.year)
To do this you just add the 2 tables in the query builder with no join at all, then add in the "Filter Data" tab your "where condition".
It isn't possible to put computed column into "ON" when joinning talbe. The simple way is just to add a piece of code before joinning tables,
such as:
proc sql;
create view table1_1 as
select table1.*, year(calldate)as year
from table1;quit;
A work-around is to use a implicit SQL join:
FROM table1 t1, table2 t2 WHERE (year (t1.calldate) = t2.year)
To do this you just add the 2 tables in the query builder with no join at all, then add in the "Filter Data" tab your "where condition".
Thanks, Patrick. This worked.
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.