BookmarkSubscribeRSS Feed
brookeewhite1
Quartz | Level 8

I received a massive SAS data set (around 100 fields and 21 million records) with the comment that records containing the word "TEST" should be removed. The person who told me this didn't know which field(s) might contain the word TEST. Is there a way to search across all fields, without having to individually name the criteria for each field to be checked?  The only thing I can think of would be to create a concatenated field with all other fields and then search that, but even that sounds pretty labor intensive to me. Plus it will take forever and requires creating a large dataset that I don't really need. Can anyone suggest an alternative approach?

 

I am using SAS Enterprise Guide 7.1.

 

Thanks!

 

7 REPLIES 7
novinosrin
Tourmaline | Level 20

data want;
set have;
if index(catx(',',of all_your_fields:  ),"TEST")>0 then delete;
run;

Reeza
Super User

 

data have;
set sashelp.class;

flag = find( catx(" ", of _character_), "fred", 'it');
run;

proc print;
run;

 

 

Basically concatenate all the character variables, search for the word TEST in that string. 

This assumes numeric variables cannot be TEST. 

 

You could also run a giant PROC FREQ - get the results in a table and then search that table for the word TEST and see which variables you need to be filtering on.

 

brookeewhite1
Quartz | Level 8

Thank you Reeza, I'm giving this a try now (waiting for it to run)! I'll be out tomorrow so probably will have to come back to this next week. I liked this option because it allows me to view the records containing TEST before I delete them. Also I liked that I didn't have to list all the variables.

Reeza
Super User

Note that the it options will strip leading/trailing spaces and ignores case in teh comparison. So in this case, test=Test=TEst etc.

 

 

brookeewhite1
Quartz | Level 8

Reeza,

 

I tried this solution, but my software keeps crashing, probably due to the amount of data being concatenated, since my data set is so large. Thanks anyway!

DrAbhijeetSafai
Lapis Lazuli | Level 10

That was helpful! 🙂

 

Thank you.

 

- Dr. Abhijeet Safai

Dr. Abhijeet Safai
Certified Base and Clinical SAS Programmer
Associate Data Analyst
Actu-Real
novinosrin
Tourmaline | Level 20

 

/*or*/

data want;
set have;
array t(*) your_fields: ;
do _n=1 to dim(t);
if index(t(_n),"TEST")>0 then do;
_f=1;
leave;
end;
if _f then delete;
drop _:;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 7 replies
  • 3200 views
  • 2 likes
  • 4 in conversation