BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
art297
Opal | Level 21

KSharp,

Would you explain your regular expression?  Appreciated, Art

Ksharp
Super User

Art

/'\s*\d{4}\s*-\s*\d{1,2}\s*-\s*\d{1,2}\s*'/o

\s*  means matching zero or more times SPACE character.

\d{4}  means matching exactly four digits.

\d{1,2}    means matching one to  two  times digits(i.e.   \d or \d\d)

o  means only compiling perl regular expression once.

-   means matching exactly - character.

'   means matching exactly ' character

Ksharp

Message was edited by: xia keshan

Patrick
Opal | Level 21

Just for the fun of it:

data want(keep=line);

set have;

line=prxchange("s/'(\d{4})-(\d+)-(\d+)'/%nrbquote(%)sysfunc(inputn($3$2$1,ddmmyy8.))/o", -1, line);

run;

Ksharp
Super User

Patrick.

It is very interesting. I don't realize that changing it into a macro function.

But there is a problem. Your way will make line longer, if the length of original line is not long enough to hold these macro function. then it will be truncated.

Anyway, It is an interesting solution.

Happy Christmas !

Ksharp

Cheers

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 18 replies
  • 3897 views
  • 6 likes
  • 6 in conversation