data _null_;
a = 'abc efg ';
if put(a, $revers10.) =: 'gfe' then put "a has trailing string efg";
run;
/*
Output:
a has trailing string efg
*/
Result:
Tuesday, June 12, 2018
Identify trailing string using $revers.
In SAS, it is easy to identify leading string using ":" operator modifier, e.g. "a =: b". However, there was no easy way to identify trailing ones. Traditionally we could use combination of substr/reverse/length/strip functions. Personally I prefer format $revers as it combines the functionality of substr and left-align. Note that the width should be the length of the character variable.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment