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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3386 views
  • 6 likes
  • 6 in conversation