Desktop productivity for business analysts and programmers

joining on a computed column in eg

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

joining on a computed column in eg

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



Accepted Solutions
Solution
‎06-26-2012 11:16 AM
Respected Advisor
Posts: 3,837

Re: joining on a computed column in eg

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".

View solution in original post


All Replies
Contributor QLi
Contributor
Posts: 57

Re: joining on a computed column in eg

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;

Solution
‎06-26-2012 11:16 AM
Respected Advisor
Posts: 3,837

Re: joining on a computed column in eg

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".

Occasional Contributor
Posts: 5

Re: joining on a computed column in eg

Thanks, Patrick. This worked.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 2175 views
  • 3 likes
  • 3 in conversation