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) 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
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
Thank you so much Xia, it worked! Thanks all!
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.
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.
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.