Which function could I use to remove the blank in front of string? Is there any function that works like left() of SAS? Thanks.
There doesn't appear to be an LTRIM function. Here's one way to do it, using a regular expression.
/*
Function Name: ltrim
Description: Trim any spaces on the left side of a string.
Arguments:
in_string String to do the left trim on
Sample calls:
a = " ddd eee fff ";
print(ltrim(a));
c = "abcde";
print(ltrim(c));
*/
ltrim = Function( {in_string},
{Default Local},
// Use the regular expression "^ *" which means start at the beginning of the string
// and match any number of sequential spaces
start_nonspace = length(Regex(in_string, "^ *"));
ltrim_string = substr(in_string, (start_nonspace+1));
ltrim_string;
);
There doesn't appear to be an LTRIM function. Here's one way to do it, using a regular expression.
/*
Function Name: ltrim
Description: Trim any spaces on the left side of a string.
Arguments:
in_string String to do the left trim on
Sample calls:
a = " ddd eee fff ";
print(ltrim(a));
c = "abcde";
print(ltrim(c));
*/
ltrim = Function( {in_string},
{Default Local},
// Use the regular expression "^ *" which means start at the beginning of the string
// and match any number of sequential spaces
start_nonspace = length(Regex(in_string, "^ *"));
ltrim_string = substr(in_string, (start_nonspace+1));
ltrim_string;
);
Thanks a lot for your instruction again. Your answer is always helpful.
Trim() supports an optional "left", "both" or "right" argument. Default is to trim trailing whitespace at both ends.
s = " Column Name ";
Trim( s, left );
That was a quick and simple answer. Thanks for your input.
I should have RTFM'd. Thanks for pointing that out MS!