BookmarkSubscribeRSS Feed
Wirus
Calcite | Level 5

Hi,

I'm a little confused by the result of this query. At first I create two data sets with one common observation (value 2). Then I want to get this common observation from set a, but for some reason I get 3 as result. Can someone explain why is the code not working as I planned?

data a;
input x;
cards;
1
2
3
;
run;

data b;
input x;
cards;
2
4
;
run;


proc sql;
select * from a where x=(select * from a intersect select * from b);
quit;

2 REPLIES 2
stat_sas
Ammonite | Level 13

Hi,


May be this is what you are looking for.


proc sql;

select * from a where x in (select x from b);

quit;

PGStats
Opal | Level 21

It does look wrong, and so do the results from

proc sql;

select x, (select x from a intersect select x from b) as y from a;

select x, (select x from b intersect select x from a) as y from a;

quit;

You should submit a "Problem Report" to SAS (link at the bottom of the page) .

PG

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 785 views
  • 0 likes
  • 3 in conversation