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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 18 replies
  • 1776 views
  • 6 likes
  • 6 in conversation