We Recommend

Mastering Regular Expressions Mastering Regular Expressions
As this book shows, a command of regular expressions is an invaluable skill. Regular expressions allow you to code complex and subtle text processing that you never imagined could be automated. Regular expressions can save you time and aggravation. They can be used to craft elegant solutions to a wide range of problems. Once you've mastered regular expressions, they'll become an invaluable part of your toolkit. You will wonder how you ever got by without them.


Posted By

webonomic on 05/03/08


Tagged

parse String


Versions (?)


SAS String Parsing


Published in: SAS 


URL: http://jaredprins.squarespace.com/blog/2008/5/15/fun-with-parsing-strings-in-sas.html

Need to construct and ID of the first 5 letters and the last 7 digits

  1. /* We want to parse the current ID LOLOBRIDGIDA195703F and end up with an ID of the first 5 letters and the last 7 digits to end up with LOLOB195703F */
  2.  
  3. data _null_;
  4. length id2 $12;
  5. id = 'LOLOBRIDGIDA195703F';
  6. id2 = substr(id,1,5)||reverse((substr(reverse(id),1,7)));
  7. put _all_;
  8. run;

Report this snippet 

You need to login to post a comment.