SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

I would like to ask 2 questions please:

Question 1:

 prxmatch('/ttt\d{8}/i',MEMNAME) 

What does it mean ?

As I see it tells to take data sets names that have the word "ttt"?

What does it mean d{8}/i'???

Question 2:

input("&start",DDMMYY8.) <= input(compress(MEMNAME,,'a'),DDMMYY8.) <= input("&end",MMDDYY8.);

As I understand the date in data set name should be between start and end.

What does it mean  input(compress(MEMNAME,,'a'),DDMMYY8.)??

I understand that input (......,DDMMYY8.) convert char to SAS date.

compress deleting spaces, what 'a' is doing?

Is it removing all upper and lower case characters from String (and only numbers left)?

 

thank you 

 

 

 

and prxmatch('/ttt\d{8}/i',MEMNAME)
and input("&start",DDMMYY8.) <= input(compress(MEMNAME,,'a'),DDMMYY8.) <= input("&end",MMDDYY8.);

 

data ttt01032021;
input x y;
cards;
1 10
;
run;

data ttt02032021;
input x y;
cards;
2 11
;
run;

data ttt03032021;
input x y;
cards;
5 18
;
run;

data ttt06032021;
input x y;
cards;
6 16
;
run;


data ttt08032021;
input x y;
cards;
7 19
;
run;

%let start=01032021;
%let end=06032021;

proc sql noprint;
select MEMNAME into :ds separated by ' '
from dictionary.tables
where LIBNAME = 'WORK' 
and prxmatch('/ttt\d{8}/i',MEMNAME) 
and input("&start",DDMMYY8.) <= input(compress(MEMNAME,,'a'),DDMMYY8.) <= input("&end",MMDDYY8.);
quit;
%put &ds;

5 REPLIES 5
Ronein
Meteorite | Level 14
Thank you,
I still dont understand what is this condition : prxmatch('/ttt\d{8}/i',MEMNAME)
I expect that when there is condition then we should have equal sign "=" and here there is no equal sign.
May you please write in words what is the meaning of this condition :prxmatch('/ttt\d{8}/i',MEMNAME)
Ronein
Meteorite | Level 14

So probably prxmatch('/ttt\d{8}/i',MEMNAME)  is equivalent to prxmatch('/ttt\d{8}/i',MEMNAME) =1  ??

Why is it like that??

How SAS guess that prxmatch('/ttt\d{8}/i',MEMNAME)   is  =1??

Kurt_Bremser
Super User

You really, really, really need to start studying the documentation. It's all in there:

PRXMATCH Function

Searches for a pattern match and returns the position at which the pattern is found.

 

To illustrate this, run a short example (Maxim 4):

data test;
input memname $32.;
pmatch = prxmatch('/ttt\d{8}/i',MEMNAME);
datalines;
xxx
ttt
ttt20210315
TTT20210315
ttt202103159
xxxttt20210315
;

You can see the returned positions.

Since SAS considers any numeric value not in (.,0) as true, the function can be used as the sole argument to a condition.

japelin
Rhodochrosite | Level 12

It's not that you don't understand prxmatch, it's just that you don't understand that the notation 'and prxmatch('/ttt\d{8}/i',MEMNAME)' is a condition.


prxmatch('/ttt\d{8}/i',MEMNAME)  equal

prxmatch('/ttt\d{8}/i',MEMNAME) not in (. 0).

both of them is the same.

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register 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
  • 5 replies
  • 1192 views
  • 0 likes
  • 3 in conversation