BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasphd
Lapis Lazuli | Level 10

I want to delete rows when a variable name contain a string (INFRA)

 

have 

 

id name 

1 don infra

2 waw 

3 sik infra

4 dfh

 

want 

id name

2 waw 

4 dfh

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data have;
input id name & $20.;
cards;
1 don infra
2 waw 
3 sik infra
4 dfh
;

data want;
set have;
if not ^^find(name,'infra','i');
run;

View solution in original post

5 REPLIES 5
Astounding
PROC Star

Does "infra" vs. "INFRA" make a difference?  One possibility:

 

data want;

set have;

if index(upcase(name), "INFRA") = 0;

run;

sasphd
Lapis Lazuli | Level 10

No it does not matter. 

however the program does not work. what I want is to delete rows containing the string "infra" 

Astounding
PROC Star

So why do you say it does not work?

novinosrin
Tourmaline | Level 20
data have;
input id name & $20.;
cards;
1 don infra
2 waw 
3 sik infra
4 dfh
;

data want;
set have;
if not ^^find(name,'infra','i');
run;
novinosrin
Tourmaline | Level 20

Or with FINDW

 

data have;
input id name & $20.;
cards;
1 don infra
2 waw 
3 sik infra
4 dfh
;

data want;
set have;
if not ^^findw(name,'infra',' ','i');
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 4384 views
  • 2 likes
  • 3 in conversation