BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
oldschool
Calcite | Level 5

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


1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

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

3 REPLIES 3
QLi
Fluorite | Level 6 QLi
Fluorite | Level 6

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;

Patrick
Opal | Level 21

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

oldschool
Calcite | Level 5

Thanks, Patrick. This worked.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 9830 views
  • 4 likes
  • 3 in conversation