Is there a function that strips off leading blanks? (i.e., left justifies a string variable). the alphabetic list of statements claims that "strip" will strip off leading and trailing blanks, but the function definition itself says just trailing blanks (& that is correct).
I am importing a lookup file from stata's "outfile" command. [stata, alas, seems to write out an ANSI data file that CSPro cannot convert correctly, so in an editor (vi) I preface it with an ISO character(?) taken from one of my CSPro data files, and that seems to make it readable by CSPro]. But stata usually right justifies its output string variables and I can't strip off the leading blanks in CSPro. And when I force stata to left justify the output, it still has two leading blanks in all the string fields.
And I thought this was going to be easier than going through Excel...
strip leading blanks/ left justify?
Re: strip leading blanks/ left justify?
Yes, strip only strips whitespace at the end of the string. I don't think there is a built in function that strips leading spaces but you can write one:
function string lstrip(string s)
numeric i;
do i = 1 while i < length(s) and s[i:1] = " "
enddo;
lstrip = s[i:length(s)-i];
end
Thanks for pointing out the error in the help. We will fix that.numeric i;
do i = 1 while i < length(s) and s[i:1] = " "
enddo;
lstrip = s[i:length(s)-i];
end