Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Remove last two characters of a string variable

1,887 views
Skip to first unread message

walf...@gmail.com

unread,
Jun 28, 2013, 7:43:47 PM6/28/13
to
Hi,

I need to remove the last two characters of a string variable, all of which differ in their last two characters. For instance, from AL0011200 -> AL00112. Whereas I know how to delete it if all the observations were of the same length, in this dataset, the number of characters varies substantially.

Many thanks in advance,
Scott

Bruce Weaver

unread,
Jun 28, 2013, 9:12:56 PM6/28/13
to
From the FM:

CHAR.LENGTH. CHAR.LENGTH(strexpr). Numeric. Returns the length of
strexpr in characters, with any trailing blanks removed.

CHAR.SUBSTR. CHAR.SUBSTR(strexpr,pos[,length]). String. Returns the
substring beginning at character position pos of strexpr. The optional
third argument represents the number of characters in the substring. If
the optional argument length is omitted, returns the substring beginning
at character position pos of strexpr and running to the end of strexpr.
For example CHAR.SUBSTR(’abcd’, 2) returns ’bcd’ and CHAR.SUBSTR(’abcd’,
2, 2) returns ’bc’. (Note: Use the SUBSTR function instead of
CHAR.SUBSTR if you want to use the function on the left
side of an equals sign to replace a substring.)

--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."
0 new messages