Help using Base SAS procedures

how to combine 2 inner joins to proc sql

Reply
Regular Contributor
Regular Contributor
Posts: 238

how to combine 2 inner joins to proc sql

I have the following 3 proc sqls and trying to figure out how to make them just 1.  The reason for this is I have a total of proc1 through proc20. I need to compared proc1 in main table to proc1 in second table. then proc2 in main table to proc2 in second table. then proc1 in main table to proc1 in second table and proc3 in main table to proc2 in second table. And so on.

proc sql;

create table p1 as

(select a.*,

  1. b.proc1 as tbl1_proc1,
  2. b.proc2 as tbl1_proc2,
  3. b.edit

from

phyclms a

inner join c0 b

on a.proc1=b.proc1 and a.proc2=b.proc2

group by a.clm_aud_nbr);

quit;

proc sql;

create table p2 as

(select a.*,

  1. b.proc1 as tbl1_proc1,
  2. b.proc2 as tbl1_proc2,
  3. b.edit

from

phyclms a

inner join c0 b

on a.proc1=b.proc1 and a.proc3=b.proc2

group by a.clm_aud_nbr);

quit;

proc sql;

create table p3 as

(select a.*,

  1. b.proc1 as tbl1_proc1,
  2. b.proc2 as tbl1_proc2,
  3. b.edit

from

phyclms a

inner join c0 b

on a.proc1=b.proc1 and a.proc3=b.proc2

group by a.clm_aud_nbr);

quit;

Super Contributor
Posts: 307

Re: how to combine 2 inner joins to proc sql

I don't really understand what you are trying to accomplish. Your description of the problem is somewhat unclear. In addition, your 2nd and 3rd PROC SQL statements appear to be identical.

In any case, have you considered using a series of LEFT joins instead of INNER joins?

Regular Contributor
Regular Contributor
Posts: 238

Re: how to combine 2 inner joins to proc sql

Let me put together a data have. Might make better sense.

Ask a Question
Discussion stats
  • 2 replies
  • 133 views
  • 0 likes
  • 2 in conversation