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;
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;
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?
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.