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

Hi,

 

When I performs an SQL join with a derived join key, I separates the step into proc sql. One to drive the joinkey and another to actually perform the join. I wonder if someone know of a more efficient way to do this. A simple example below to illustrate,

 

proc sql;

  create view prep_table as

  select * ,put(raw_var, $someformat.) as joinkey

  from main_table;

 

  create table output_table as

  select a.var ,b.var2

  from prep_table as a

    left join sub_table as b

      on a.joinkey = b.joinkey;

  quit;  

1 ACCEPTED SOLUTION

Accepted Solutions
kiranv_
Rhodochrosite | Level 12

but what is point to make another column in the view, unless your building a index or something useful. You can do pretty much in same step as 

 

 

  create table output_table as

  select a.var ,b.var2

  from prep_table as a

    left join sub_table as b

      on put(a.raw_var, $someformat.) = b.joinkey;

  quit;  

  

View solution in original post

2 REPLIES 2
kiranv_
Rhodochrosite | Level 12

but what is point to make another column in the view, unless your building a index or something useful. You can do pretty much in same step as 

 

 

  create table output_table as

  select a.var ,b.var2

  from prep_table as a

    left join sub_table as b

      on put(a.raw_var, $someformat.) = b.joinkey;

  quit;  

  

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1162 views
  • 0 likes
  • 2 in conversation