DATA Step, Macro, Functions and more

String query in Arrays

Reply
Contributor
Posts: 71

String query in Arrays

[ Edited ]

I have a dataset like below

No Process
1 AB C
2 AB D
3 XYZ
4 YYY
5 AB C
6 XYZ
7 DE F
8 AB D
9 AB D
10 YYY

I want to find the values that does not contain AB* as follows using arrays.

No Process
3 XYZ
4 YYY
6 XYZ
7 DE F
10 YYY

 

Please advise.

Super User
Posts: 19,770

Re: String query in Arrays

Where do arrays come into the process?

 

It should be a single filter, either a WHERE or IF statement.

 

if indexw( process, 'AB') > 0 then keep;

or 

 

WHERE process like '%AB%';
Super User
Posts: 10,020

Re: String query in Arrays


data have;
input No Process $;
cards;
1 AB C
2 AB D
3 XYZ
4 YYY
5 AB C
6 XYZ
7 DE F
8 AB D
9 AB D
10 YYY
;
run;

data want;
 set have;
 if upcase(process) =: 'AB' then delete;
run;


Trusted Advisor
Posts: 1,137

Re: String query in Arrays

alternatively with perl regular expression

 

if prxmatch('m/(AB)/',process) then delete;
Thanks,
Jag
Ask a Question
Discussion stats
  • 3 replies
  • 111 views
  • 0 likes
  • 4 in conversation