| Date: | Wed, 30 Oct 2002 16:33:28 -0500 |
| Reply-To: | "Dorfman, Paul" <Paul.Dorfman@BCBSFL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Dorfman, Paul" <Paul.Dorfman@BCBSFL.COM> |
| Subject: | Re: removing characters/digits from an ID |
|
| Content-Type: | text/plain; charset=iso-8859-1 |
> -----Original Message-----
> From: John J Genzano, III [mailto:jgenzano@GENZANO.COM]
>
> Or you could use my favorite function; REVERSE!!
>
> select(group);
> WHEN('a') id = REVERSE(SUBSTR(REVERSE(TRIM(id1)),4));
> WHEN('b') id = REVERSE(SUBSTR(REVERSE(TRIM(id1)),3));
> end;
John,
What has REVERSE done to achieve such a status in your eyes :-)? I concede,
though, that it is indeed quite useful under many circumstances. However, I
would think just from what it does that it could be quite
resource-intensive, let alone applying it twice. In this particular case,
all we need to do is overprint 2 or 3 bytes with spaces:
substr(id, length(id) - &n + 1) = '' ;
where &n is the number of bytes to overprint. For a fairly long ID, I bet it
will execute good 50% faster, and probably still faster than
id = substr (id, 1, length(id) - &n) ;
That again should be the more pronounced, the longer the ID.
Kind regards,
-----------------------
Paul M. Dorfman
Jacksonville, FL
-----------------------
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Goldman, Brad (AT-Atlanta)
> Sent: Wednesday, October 30, 2002 1:46 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Question RE: removing characters/digits from an ID
>
>
> > ID Group
> > 111111111FD2 a
> > 22222222FS1 a
> > 333333301 b
> > 44444444410 b
> >
> > and I would like to get:
> > ID Group
> > 111111111 a
> > 22222222 a
> > 3333333 b
> > 444444444 b
> >
> > In that for group "a" I would like to remove the right 3
> and for group
> > "b" I would like to remove the right 2.
>
> select (group);
> when (a) id=substr(id,1,length(id)-3);
> when (b) ...
> otherwise; end;
>
> or perhaps create a format for group? <very untested>
> id=substr(id,1,length(id)-put(group,groupfmt.));
>
> Brad
>
Blue Cross Blue Shield of Florida, Inc., and its subsidiary and
affiliate companies are not responsible for errors or omissions in this e-mail message. Any personal comments made in this e-mail do not reflect the views of Blue Cross Blue Shield of Florida, Inc.
|