Date: Wed, 29 May 2002 06:53:34 -0400
Reply-To: Howard_Schreier@ITA.DOC.GOV
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard_Schreier@ITA.DOC.GOV
Subject: Re: Issue: How to conditionally add a text string to a variable.
The TRIM function is definitely needed. This is one of the all-time SAS
Traps.
The LEFT function is a different story. First, one has to know if it's
appropriate to eliminate leading blanks. If it is, use LEFT to do so. But
the order in which LEFT and TRIM are applied is important. Matthew's code
will eliminate pre-existing trailing blanks, then transform leading blanks
into new trailing blanks. To eliminate both leading and trailing blanks,
it's
... Variable_Email=trim(left(Variable_Email))||'@pace.edu';
On Tue, 28 May 2002 15:52:46 -0700, Matthew Ness <MNess@CROMEDICA.COM>
wrote:
>If you want to do something conditionally, if..then is the key. You may
>also need to use the left and trim functions to concatenate the two fields
>without leaving any space between them, as well as making the field long
>enough to accommodate the extra characters:
>
>data a;
> attrib Variable_Email format=$30.;
> Variable_Email='Jblaha';
> if Variable_Email ne ' ' then Variable_Email=left(trim(Variable_Email))||
>'@pace.edu';
> run;
>
>HTH,
>Matt
>
>
>
>
>
> James Blaha
> <jblaha@PACE.E To: SAS-L@LISTSERV.UGA.EDU
> DU> cc:
> Sent by: Subject: Issue: How to
conditionally add a
> "SAS(r) text string to a variable.
> Discussion"
> <SAS-L@LISTSER
> V.UGA.EDU>
>
>
> 28/05/02 03:33
> PM
> Please respond
> to James Blaha
>
>
>
>
>
>
>Hello All:
>
>Issue: How to conditionally add a text string to a variable.
>
>I would like to know if anyone has an example of some SAS code that
>checks a character field and if it has data it will add a text string to
>it.
>
>Example:
>
>Variable_Email
>Jblaha
>
>When the program runs it checks to see if there is data in
>"Variable_Email." If there is data in the variable it will add on a text
>string "@pace.edu" Other wise it will do nothing but check the next
>observation.
>
>End result
>
>Variable_Email
>Jblaha@pace.edu
>
>Thanks,
>James Blaha
|