Type : CREATION_INTERNE
The macro does not process any dataset. It operates on a character string provided as a parameter. The 'data' source is therefore internal to the macro call.
| 1 | %put MACRO CALLED: dropmodifmac v1.0; |
| 2 | |
| 3 | %macro dropmodifmac(str); |
| 4 | %local tempstr; |
| 5 | %*- non-greedy replace stuff in double quotes with "" -; |
| 6 | %let tempstr=%sysfunc(prxchange(s!%str(%"-).*?%str(%"-)!""!,-1, |
| 7 | %superq(str))); |
| 8 | %*- non-greedy replace stuff in single quotes with '' -; |
| 9 | %let tempstr=%sysfunc(prxchange(s!%str(%'-).*?%str(%'-)!''!,-1, |
| 10 | %superq(tempstr))); |
| 11 | %*- repeat until we have no more left round brackets -; |
| 12 | %DO %while( %index(%superq(tempstr),%str(%()) ); |
| 13 | %*- Non-greedy replace stuff inside "( )" that does -; |
| 14 | %*- not include a left round bracket with null. -; |
| 15 | %let tempstr=%sysfunc(prxchange(s!\%str(%()[^\%str(%()]*?\%str(%))!!,-1, |
| 16 | %superq(tempstr))); |
| 17 | %END; |
| 18 | &tempstr |
| 19 | %mend dropmodifmac; |