|
|
 | | From: | Ya Huang | | Subject: | Re: Looking for something equivalent to RTRIM | | Date: | 21 Jan 05 21:24:41 GMT |
|
|
 | On Fri, 21 Jan 2005 12:59:06 -0800, omugeye wrote:
>substr(right(chaV), 10, -1) worked for me with no error. Am running >version 9.1. > >Well, the beauty of SAS is being able to do one thing several different >ways. As has been demonstrated here. One of these solutions must have >worked for Chadd Webb. Clearly some are more efficient than others.
Can you explain what exactly '-1' do here? Does it mean to start from 10th byte and backward extract one byte? Would it result in a single character?
Thanks
|
|
 | | From: | Dale McLerran | | Subject: | Re: Looking for something equivalent to RTRIM | | Date: | 21 Jan 05 22:08:01 GMT |
|
|
 | --- Ya Huang wrote:
> On Fri, 21 Jan 2005 12:59:06 -0800, omugeye > wrote: > > >substr(right(chaV), 10, -1) worked for me with no error. Am running > >version 9.1. > > > >Well, the beauty of SAS is being able to do one thing several > different > >ways. As has been demonstrated here. One of these solutions must > have > >worked for Chadd Webb. Clearly some are more efficient than others. > > Can you explain what exactly '-1' do here? Does it mean to start from > 10th byte and backward extract one byte? Would it result in a single > character? >
Ya,
In version 9.x, a negative length expression has the following consequence (taken straight from the online docs http://support.sas.com/onlinedoc/912/docMainpage.jsp)
If length is zero, a negative value, or larger than the length of the expression that remains in string after position, SAS extracts the remainder of the expression. SAS also sets _ERROR_ to 1 and prints a note to the log indicating that the length argument is invalid.
So, a negative length value is an invalid expression. The substr function sets the _ERROR_ indicator, but otherwise operates as though no length function was specified.
Dale
===== --------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@NO_SPAMfhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------
__________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail
|
|
 | | From: | omugeye | | Subject: | Re: Looking for something equivalent to RTRIM | | Date: | 21 Jan 2005 16:35:21 -0800 |
|
|
 | Once I saw last10char variable as desired, I shut down. I was in such a rush I did not check the log. SAS V9 posts an error in the log, and then quietly proceeds to get the right result!!!!!! The scan function is appealing
Nevertheless am glad my code strangely worked by default by some strange magic; and insipired so many other more appropriate responses!!
|
|
|