BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Olaajay
Calcite | Level 5

Please how do I re-write the code below:


DATA sample;

Set new;

  IF var in('1','2','3') THEN DELETE ;

Run;

So that, 1,2,3 is located in a table/permanent file and “var” is referencing a column in that table (ie I don’t want my code above to show 1,2,3 upfront).

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

1) Hash Table.

2) proc format

3) Array

4) SQL

5) IML code

Here is a SQL code.

proc sql;

create table sample as

select * from new

where var not in ( select key from key_table );

quit;

Xia Keshan

View solution in original post

3 REPLIES 3
Ksharp
Super User

1) Hash Table.

2) proc format

3) Array

4) SQL

5) IML code

Here is a SQL code.

proc sql;

create table sample as

select * from new

where var not in ( select key from key_table );

quit;

Xia Keshan

Olaajay
Calcite | Level 5

Thank you so much Xia, it worked! Thanks all!

Astounding
PROC Star

SAS supports many versions of table look-up:  merging, formats, hash tables, SQL.  Somebody will have to correct my syntax here, since my SQL is weak.  But something alone these lines would do it:

proc sql;

create table sample as select * from new

   /* some kind of union here with the other table to remove matches */

;

quit;

Sorting and merging would be simple, but requires sorting first.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1670 views
  • 0 likes
  • 3 in conversation