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
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;
Does "infra" vs. "INFRA" make a difference? One possibility:
data want;
set have;
if index(upcase(name), "INFRA") = 0;
run;
No it does not matter.
however the program does not work. what I want is to delete rows containing the string "infra"
So why do you say it does not work?
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;
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.