BookmarkSubscribeRSS Feed
apple
Calcite | Level 5
House_IDCodeApple
1011
1021
2021
3011
4010

I have a dataset similar to the above but with many more rows and more complicated.

I would like to select the distinct House_ID with NO Code=02 &  Apple=1, in other words House_ID=3.

If I use the below I get ALLc Sq the House_ID with Apple=1, as well the House_ID

not in (select distinct House_ID from have

where Code  in ('02')

Proc Sql;

select distinct House_ID

from have

where House_ID not in (select distinct House_ID from have

where Code  in ('02')) & Apple=1 ;

quit;




1 REPLY 1
vishal_prof_gmail_com
Obsidian | Level 7

Hi,

Subquery is not required here , also it slows down the performance.

Proc Sql;

select distinct House_ID

from have

where House_ID <> '02' and Apple=1 ;

quit;


Just confirm the syntax for not equal to expression : <>


Vishal

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 350 views
  • 0 likes
  • 2 in conversation