- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Bonjour les experts,
Savez-vous, s’il vous plaît, comment marquer les espaces à l’intérieur de la fonction prxmatch :
Je souhaite avoir les données avec T6 et T 6 :
if (prxmatch("/T6/",lb_c)>0 and (prxmatch("/T 6/",lb_c)>0
Merci !
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Utilisez le mot-clé \s pour supprimer les espaces.
if prxmatch("/T\s*6/",lb_c)>0
Here * means zero space or at least one space.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Bonjour @SASdevAnneMarie,
data test; input lb_c $20.; crit1=prxmatch("/T6/",lb_c) and prxmatch("/T 6/",lb_c); crit2=prxmatch("/T6/",lb_c) or prxmatch("/T 6/",lb_c); label crit1='Contains both "T6" and "T 6"' crit2='Contains "T6" or "T 6" (or both)'; cards; ...... ...T6... ...T 6... ...T 6...T6... ...T6...T 6... ; proc print data=test label; run;
Result:
Contains Contains "T6" or both "T6" "T 6" Obs lb_c and "T 6" (or both) 1 ...... 0 0 2 ...T6... 0 1 3 ...T 6... 0 1 4 ...T 6...T6... 1 1 5 ...T6...T 6... 1 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
More people could help you if you ask your question in English, provide some test data in usable form and results of your experiments up to now...
Try this:
data have;
input lb_c $ 64.;
cards;
T6 /* yes */
T 6 /* yes */
ABC T6 DEF /* yes */
abc T 6 def /* yes */
abc TX6 efg /* no */
abcT6efg /* ??? */
abcT 6efg /* ??? */
;
run;
proc print;
run;
data want;
set have;
flag = prxmatch("/T6|T\ 6/",lb_c)>0;
run;
proc print;
run;
EDIT:
Alternative form:
flag = prxmatch("/(T( )?6)/",lb_c)>0;
Bart
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
No worries, we figured the problem out and that's the most important! 🙂 🙂
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Utilisez le mot-clé \s pour supprimer les espaces.
if prxmatch("/T\s*6/",lb_c)>0
Here * means zero space or at least one space.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The "\s*" will give us "T6" (zero spaces), and "T 6"(one space), but also "T 6" (thousands spaces). Wasn't to OP about 0 or 1 space? Or did I misunderstand it?
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
if prxmatch("/T\s?6/",lb_c)>0