« Delivering Gift Baskets in Edmonton | Main | Excellant MS Excel Resource »

Fun with parsing strings in SAS

The goal of this code is to parse the first 5 letters of the variable and append it to the last 7 digits of the variable.

data _null_;
  length id2 $12;
  id = 'LOLOBRIDGIDA195703F';
  id2 = substr(id,1,5)||reverse((substr(reverse(id),1,7)));
  put _all_;
run;

View the code in my snippet repository.

Kudos to the guys in the SAS google group thread for this solution. 

Posted on Friday, May 16, 2008 by Registered CommenterJared in | CommentsPost a Comment

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>