BookmarkSubscribeRSS Feed
SASdevAnneMarie
Rhodochrosite | Level 12

Hello Experts,

 

Today, I'm using the following code to extract rates. I'm wondering if I can create a macro using PRXMATCH to check the values,  from 0.50% to 2.70% ?

 

if (prxmatch("/\b0[,\.]45\s*%/",lb_lg)>0
or prxmatch("/\b0[,\.]45\s*%/",lb_)>0)
or (prxmatch("/\b0[,\.]45\s*%/",lb_lg)>0
or prxmatch("/\b0[,\.]45\s*%/",lb)>0) then
do;
Taux=0.0045;
end;

if (prxmatch("/\b0[,\.]50\s*%/",lb_lg)>0
or prxmatch("/\b0[,\.]50\s*%/",lb)>0)
or (prxmatch("/\b0[,\.]5\s*%/",lb_lg)>0
or prxmatch("/\b0[,\.]5\s*%/",lb)>0) then
do;
Taux=0.005;
end;

if prxmatch("/\b1(\.0\b|\.0\%|\%|\s)/",lb_lg)>0 
or prxmatch("/\b1(\.0\b|\.0\%|\%|\s)/",lb)>0 then
do;
Taux=0.01;
end;

Thank you !

1 REPLY 1
PaigeMiller
Diamond | Level 26

I think far easier is to convert the text which you describe as 0.50% to 2.70% to actual numbers and then checking becomes much much much much easier. And then likely no macro is needed.

--
Paige Miller

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch Now →
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 83 views
  • 1 like
  • 2 in conversation