Help using Base SAS procedures

delete if contains/where contains?

Reply
Occasional Contributor
Posts: 13

delete if contains/where contains?

Hello -

I need to delete observations from my dataset when the entry for a given variable contains a certain character (@).  I want to keep all the other observations.   This seems to require something between an if-then statement and a where contains statement.  I can't seem to find any references to this situation.  Can anyone suggest the best way to do this?

Thank you.

Trusted Advisor
Posts: 1,228

Re: delete if contains/where contains?

Try something like this

if findc(text,'(@)') then delete;

Valued Guide
Posts: 2,177

Re: delete if contains/where contains?

Or sql like

PROC SQL ;

DELETE FROM your.dataset

  WHERE that_variable CONTAINS '@' ;

;

QUIT;

The contains keyword can be replaced with the symbol ? to make the syntax shorter (not neccessarily clearer)

Ask a Question
Discussion stats
  • 2 replies
  • 647 views
  • 0 likes
  • 3 in conversation