[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

SAS/SQL

Hi,

I want to change the following SQL-code with 2 input-tables to a SQL-code with 3 input-tables.
PROC SQL;
    CREATE TABLE outp AS      
    SELECT A.*, B.*
        FROM inp1 A INNER JOIN inp2 B
        ON A.key = B.key ;
QUIT ;

How can i do that.

Tx
0
sonmic
Asked:
sonmic
  • 2
1 Solution
 
bradanelsonCommented:
Depends.  There are many ways to introduce a 3rd table.  It all depends on how you want to join the table.  Here is a basic example of what I'm talking about.  This example joins inp3 buy INNER JOIN to inp2.  Like I said, there are many other ways to join that will give you different results.  For instance you can do a LEFT JOIN as well.

PROC SQL;
    CREATE TABLE outp AS      
    SELECT A.*, B.*
        FROM inp1 A

        INNER JOIN inp2 B
        ON A.key = B.key

        INNER JOIN inp3 C
        ON B.key=C.key;
QUIT ;
0
 
bradanelsonCommented:
To select fields from inp3 you need to add to the SELECT statement.

PROC SQL;
    CREATE TABLE outp AS      
    SELECT A.*, B.*. C.*
        FROM inp1 A

        INNER JOIN inp2 B
        ON A.key = B.key

        INNER JOIN inp3 C
        ON B.key=C.key;
QUIT ;


Good Luck
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now