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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.