| House_ID | Code | Apple |
|---|---|---|
| 1 | 01 | 1 |
| 1 | 02 | 1 |
| 2 | 02 | 1 |
| 3 | 01 | 1 |
| 4 | 01 | 0 |
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;
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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.