BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

Hello:

 

Could someone help me to simply the codes below? Maybe macro or array? or something else?  Thanks.

 

 

data want;

set have;

Labelpos1=find(label," NOS","i");

Labelpos2=find(label,"NOS ","i");

Labelpos3=find(label,"-NOS","i");

Labelpos4=find(label,"NOS-","i");

Labelpos5=find(label,"MISC","i");

Componentpos1=find(Component," NOS","i");

Componentpos2=find(Component,"NOS ","i");

Componentpos3=find(Component,"-NOS","i");

Componentpos4=find(Component,"NOS-","i");

Componentpos5=find(Component,"MISC","i");

Productpos1=find(Product," NOS","i");

Productpos2=find(Product,"NOS ","i");

Productpos3=find(Product,"-NOS","i");

Productpos4=find(Product,"NOS-","i");

Productpos5=find(Product,"MISC","i");

run;

 

data nos;

set want;

where Labelpos1 ne 0 or Labelpos2 ne 0 or Labelpos3 ne 0 or Labelpos4 ne 0 or Labelpos5 ne 0

or Componentpos1 ne 0 or Componentpos2 ne 0 or Componentpos3 ne 0 or Componentpos4 ne 0 or Componentpos5 ne 0

or Productpos1 ne 0 or Productpos2 ne 0 or Productpos3 ne 0 or Productpos4 ne 0 or Productpos5 ne 0;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Or, if you don't need to keep each find location:

 

data have;
  informat label component product $4.;
  input label component product;
  cards;
this that none
this nos some
the same -nos
not not not
not not misc
;

data want;
  set have (where=(max(
      prxmatch('/NOS| NOS|-NOS|NOS-|MISC/i',label),
      prxmatch('/NOS| NOS|-NOS|NOS-|MISC/i',Component),
      prxmatch('/NOS| NOS|-NOS|NOS-|MISC/i',Product) ) gt 0));
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

5 REPLIES 5
Ksharp
Super User
data _null_;
x='Could someone help me NOS';
if prxmatch('/NOS| NOS|-NOS|NOS-/i',x) then putlog 'Found';
run;
art297
Opal | Level 21

Or, if you don't need to keep each find location:

 

data have;
  informat label component product $4.;
  input label component product;
  cards;
this that none
this nos some
the same -nos
not not not
not not misc
;

data want;
  set have (where=(max(
      prxmatch('/NOS| NOS|-NOS|NOS-|MISC/i',label),
      prxmatch('/NOS| NOS|-NOS|NOS-|MISC/i',Component),
      prxmatch('/NOS| NOS|-NOS|NOS-|MISC/i',Product) ) gt 0));
run;

Art, CEO, AnalystFinder.com

 

ybz12003
Rhodochrosite | Level 12

Hi Art297:

 

Your codes are wonderful.   But what is MAX used for?

art297
Opal | Level 21

I used max instead of OR. That is, if the largest resulting value from either of the three calls is greater than zero.

 

Art, CEO, AnalystFinder.com

 

ballardw
Super User

Example input is where?

Desired output is what?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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