BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASdevAnneMarie
Barite | Level 11

Hello Experts,

 

I would like to hold the code with min value from column a (in my exemple it is T244).

For this, I would like to replace the letter by spaces, and apply the min function.

Do you know please, how to do that with prxmatch function ? Thank you !

data test;
a="T244|T244O|T244S|T339";
/*if prxmatch("m/[A-Z]{1,}/oi",a)> 0 then*/
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data test;
a="T244|T244O|T244S|T339";

min=9999999;
do i=1 to countw(a,'|');
  temp=scan(a,i,'|');
  value=input(compress(temp ,,'kd'),best32.);
  if value<min then do;want=temp;min=value;end;
end;
drop min i temp value;
run;

View solution in original post

3 REPLIES 3
andreas_lds
Jade | Level 19

If you have letters and digits in your data, using compress instead of prxmatch/prxchange is recommended.

 

data test;
   a="T244|T244O|T244S|T339";
   b = compress(a, '|', 'kd');
run;

Is this the original form of the data or is "a" created to solve the problem?

Ksharp
Super User
data test;
a="T244|T244O|T244S|T339";

min=9999999;
do i=1 to countw(a,'|');
  temp=scan(a,i,'|');
  value=input(compress(temp ,,'kd'),best32.);
  if value<min then do;want=temp;min=value;end;
end;
drop min i temp value;
run;
SASdevAnneMarie
Barite | Level 11
Thank you, Ksharp !

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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