| Date: | Fri, 16 Feb 2007 15:18:29 +0000 |
| Reply-To: | toby dunn <tobydunn@HOTMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | toby dunn <tobydunn@HOTMAIL.COM> |
| Subject: | Re: Convert SAS date to text |
|
| In-Reply-To: | <456B52C41B724C41B96561D7AD283E7D052094@mail.chpdm.umbc.edu> |
| Content-Type: | text/plain; format=flowed |
|---|
Jack ,
YOu can simplify this even more by nesting your function calls:
Example:
NewYear = Put( Year( Date ) , Year4. ) ;
Toby Dunn
To sensible men, every day is a day of reckoning. ~John W. Gardner
The important thing is this: To be able at any moment to sacrifice that
which we are for what we could become. ~Charles DuBois
Don't get your knickers in a knot. Nothing is solved and it just makes you
walk funny. ~Kathryn Carpenter
From: Jack Clark <JClark@CHPDM.UMBC.EDU>
Reply-To: Jack Clark <JClark@CHPDM.UMBC.EDU>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Convert SAS date to text
Date: Fri, 16 Feb 2007 10:16:12 -0500
Lloyd,
Code below shows using day, month, year functions to pull these pieces from
a SAS date variable. It also shows converting the individual pieces to
text, if that is what you need. Check the documentation on date formats for
additional formats available for use in the PUT function.
data test;
/* create SAS date variable */
date1 = '16FEB07'd;
/* extract numeric day, month or year from SAS date */
day1 = day(date1);
month1 = month(date1);
year1 = year(date1);
/* convert numeric day, month or year to character field */
day1_c = put(day1,z2.);
month1_c = put(month1,z2.);
year1_c = put(year1,4.);
run;
Jack Clark
Research Analyst
Center for Health Program Development and Management
University of Maryland, Baltimore County
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Lloyd
Dollins
Sent: Friday, February 16, 2007 9:51 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Convert SAS date to text
I have seen postings about converting a text field into a SAS date, but
how do you do the reverse. I want to convert a SAS date into a text
field so that I can use the substring function to pull out parts of the
date.
Thanks in advance for any help provided.
_________________________________________________________________
Find a local pizza place, movie theater, and more….then map the best route!
http://maps.live.com/?icid=hmtag1&FORM=MGAC01
|