Tag Archives: substr

Using SUBSTR on the left of an assignment in SAS

This is a pretty cool feature, and as far as I know it’s unique to SAS and Perl. In SAS, you can have a substr to the left of an assignment. stringDate=’29MAR1984′; substr(stringDate,3,3)=’FEB’; This avoids potentially awkward situations like this: stringDate=’29MAR1984′; stringDate=substr(stringDate,1,2)||’FEB’||substr(stringDate,6,4); The bounds don’t have to be static. Lets suppose we have a dataset […]