Date: Tue, 2 Mar 1999 14:13:32 +0100
Reply-To: adolf-a.quast@DB.COM
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Adolf Quast <adolf-a.quast@DB.COM>
Subject: Re: Concatenating Character Variables + Converting Date Values
Content-type: text/plain; charset=us-ascii
Hi,
here are the solutions for your problems:
Note that you need the TRIM-function to get rid of trailing blanks.
/* 1. Concatenate two character-variables */
data _NULL_ ;
PRENAME = "FRED" ;
SURNAME = "LYCETT" ;
NAME = trim(PRENAME) !! " " !! trim(SURNAME) ;
put NAME= ;
run ;
Note that the solutions for DATE2 and DATE3 only show the convertion from a
character-variable
into another character-variable.
Another solution would be to create a SAS-Datevalue and define a format for it
(Variable DATE4).
/* 2. Converting Date-Values */
data TEST ;
length DATE1-DATE3 $ 10 /* character */
DATE4 8 ; /* numeric */
DATE1 = "02281999" ; /* Original date string */
DATE2 = put(input(DATE1,mmddyy8.),ddmmyy8.) ;
DATE3 = put(input(DATE1,mmddyy8.),eurdfdd10.) ; /* New european format */
DATE4 = input(DATE1,mmddyy8.) ;
put DATE1= ;
put DATE2= ;
put DATE3= ;
put DATE4= ;
format DATE4 eurdfdd10. ;
run ;
Hope that helps,
Adolf Quast
------- Original Message --------
Dear All,
I have two variables -- both are of character format. They are called
FORENAME and SURNAME. I would like to derive a new variable
)let's call it NAME) which will be as follows:
NAME = FORENAME SURNAME
So if FORENAME takes the value FRED and SURNAME the value LYCETT
then the new variable NAME will need to take
the value: FRED LYCETT.
I would appreciate very much if i would receive your comments on how
to do it, please.
In addition, I have a variable that shows the date according to
american format ie. month/day/year. I would rather prefer to have
this variable according to european format ie. dd/month/year.
May I have you suggestions on how to make the conversion, please.
Thank you very much indeed for taking the time to consider my
request. I look forward to hearing from you.
Yours Sincerely
Panos Papanikolaou
Research Fellow
SONS
UWCM
Cardiff
Great Britain