BookmarkSubscribeRSS Feed
apple
Calcite | Level 5
HH_NOX
019
013
029
031
032

I have a similar dataset but with more rows. I want to select all the HH_NO that do NOT have any X=9, like HH_NO=03

How do I do so?

Thank you

3 REPLIES 3
LinusH
Tourmaline | Level 20

Many ways to this. SQL with a subquery (inner join or where) are two.

Data never sleeps
kuridisanjeev
Quartz | Level 8

As Linush said,there are many ways to do this,

Here is one of the way,

Data test;

input a b ;

cards;

01 9

01 3

02 9

03 1

03 2

run;

Proc Sql;

select Distinct a into :value separated by ' '  from test

where b eq 9;

quit;

Data final;

set test;

if a not in (&value);

run;

Proc print;

run;

kuridisanjeev
Quartz | Level 8

One more way,

Data test;

input a b ;

cards;

01 9

01 3

02 9

03 1

03 2

run;

Proc Sql;

select A,b from test

where a not in (Select distinct a from test where b eq 9);

quit;

Thanks,

Sanjeev.K

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
  • 3 replies
  • 657 views
  • 0 likes
  • 3 in conversation