Help using Base SAS procedures

Find same observations in two tables

Accepted Solution Solved
Reply
Regular Contributor
Posts: 194
Accepted Solution

Find same observations in two tables

Hi,

I need to create a table that has the same building codes between both tables.

I want all variables from Table A

From Table B, I only want some variables;  Year, NumberUTD

Both tables may have matching building codes but we don't know.  That's what we would like to find out. 

 

 

 

 

 

 

 

 

 

 

 


Accepted Solutions
Solution
‎03-03-2017 07:07 PM
PROC Star
Posts: 307

Re: Find same observations in two tables

Something like this, though data would be helpful:

 

proc sql;
  CREATE TABLE want AS
  SELECT a.*, b.year, b.NumberUTD
  FROM tableA AS a
  INNER JOIN tableB AS b
  ON a.buildingCode = b.buildingCode;
quit;

I'm making assumptions about uniqueness of the data, variable names, etc., but something along those lines will give you what you want.

View solution in original post


All Replies
Solution
‎03-03-2017 07:07 PM
PROC Star
Posts: 307

Re: Find same observations in two tables

Something like this, though data would be helpful:

 

proc sql;
  CREATE TABLE want AS
  SELECT a.*, b.year, b.NumberUTD
  FROM tableA AS a
  INNER JOIN tableB AS b
  ON a.buildingCode = b.buildingCode;
quit;

I'm making assumptions about uniqueness of the data, variable names, etc., but something along those lines will give you what you want.

☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 176 views
  • 0 likes
  • 2 in conversation