I am trying following code:
data new;
input id Value $;
datalines;
1 50
2 1
3 500
4 56
5 1000
;
run;
data new1;
set new;
where prxmatch('/\d{2}/',Value);
run;
After submitting above code, I am getting following output:
According to following documentation
https://support.sas.com/resources/papers/proceedings/proceedings/sugi29/265-29.pdf
Expected output:
id Value
1 50
4 56
But in output I am getting 2 digit number and greater then 2 digit number even-though
my pattern is only for 2 digit number
Your pattern matches any string that includes at least two consecutive digits. Try this instead:
/^\d{2}\s*$/
Tried with following changes but getting same output as shown in above screen shot. (two consecutive digits and greater then two consecutive digits )
where prxmatch('/\d{2}\s*$/',Value);
Interesting, i get the expected results:
36 data new1; 37 set new; 38 where prxmatch('/^\d{2}\s*$/', Value); 39 put _all_; 40 run; id=1 Value=50 _ERROR_=0 _N_=1 id=4 Value=56 _ERROR_=0 _N_=2 NOTE: There were 2 observations read from the data set WORK.NEW. WHERE PRXMATCH('/^\d{2}\s*$/', Value);
The devil is in the detail. You omitted the little caret-symbol ^ from @andreas_lds 's code.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.