Help using Base SAS procedures

PROC SQL INTERSECT

Accepted Solution Solved
Reply
Contributor
Posts: 34
Accepted Solution

PROC SQL INTERSECT

Hi all,

 

What is the proc sql equivalent of this merge  ?  I tried some proc sql intersect commands and I had some strange results. 

 

data Filenew;

merge file1 (in=b) file2 (in=c);

by var1;

if b and c;

run;


Accepted Solutions
Solution
‎07-04-2016 03:38 PM
Respected Advisor
Posts: 4,644

Re: PROC SQL INTERSECT

proc sql;

create table filenew as

select file1.*, file2.*

from file1 inner join file2 on file1.var1=file2.var1;

quit;

 

select file1.*, file2.* " is not quite right. In a data step merge, you get the last value of any same-named variable, but in SQL you must specify which one you want.

PG

View solution in original post


All Replies
Solution
‎07-04-2016 03:38 PM
Respected Advisor
Posts: 4,644

Re: PROC SQL INTERSECT

proc sql;

create table filenew as

select file1.*, file2.*

from file1 inner join file2 on file1.var1=file2.var1;

quit;

 

select file1.*, file2.* " is not quite right. In a data step merge, you get the last value of any same-named variable, but in SQL you must specify which one you want.

PG
☑ This topic is SOLVED.

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

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