BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
David_Billa
Rhodochrosite | Level 12

can someone help me understand this line?

 

MAT_NBR= prxchange('s/^(0*)//', -1,NBR);
1 ACCEPTED SOLUTION

Accepted Solutions
kelxxx
Quartz | Level 8

Unless I am mistaken,

mat_nbr = remove the Matched Pattern in variable NBR , the value of times is –1, then matching patterns continue to be replaced until the end of source is reached.

Sequence: match all of the followings in order
BeginOfLine
CapturingGroup
GroupNumber:1
Repeat
0
zero or more times

 

 

=>>> remove Leading Zeros in the varible nbr

nbr = 0001 => mat_nbr=1

nbr= 001 01 => mat_nbr=1 01

View solution in original post

2 REPLIES 2
kelxxx
Quartz | Level 8

Unless I am mistaken,

mat_nbr = remove the Matched Pattern in variable NBR , the value of times is –1, then matching patterns continue to be replaced until the end of source is reached.

Sequence: match all of the followings in order
BeginOfLine
CapturingGroup
GroupNumber:1
Repeat
0
zero or more times

 

 

=>>> remove Leading Zeros in the varible nbr

nbr = 0001 => mat_nbr=1

nbr= 001 01 => mat_nbr=1 01

PGStats
Opal | Level 21

The function call removes leading zeros if starting at the first character. Is equivalent to prxchange("s/^0+//", 1, NBR). Note that prxchange("s/^\s*0+//", 1, NBR) would account for leading spaces.

PG

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
  • 2 replies
  • 392 views
  • 2 likes
  • 3 in conversation