Date: Fri, 23 Jan 2009 08:13:57 -0500
Reply-To: Nathaniel.Wooding@DOM.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject: Re: A scan function question
In-Reply-To: <200901222121.n0MH4buV011379@malibu.cc.uga.edu>
Content-Type: text/plain; charset="US-ASCII"
You have had several useful replies but the answer will lie in whether you
are reading the dates from a text file or whether they are in a SAS data
set already.
If you are reading from a text file, then simply read the first two
characters:
Data Tom;
input date $9. @1 day $2. ;
cards;
25Dec2006
02Jan2009
15Feb2009
18Nov2004
;
run;
This assumes that you want both day and date and that you want them as
character variables.
If you already have date in a SAS data set, then the answer depends on
whether you have stored the value as a character string or as a SAS date
value.
If the former, then use
day = Substr( date , 1 , 2 ) ; which will give you a character variable.
If date is numeric then use
day = day( date );
Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
Tom Smith
<need_sas_help@YA
HOO.COM> To
Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU
Discussion" cc
<SAS-L@LISTSERV.U
GA.EDU> Subject
A scan function question
01/22/2009 04:21
PM
Please respond to
Tom Smith
<need_sas_help@YA
HOO.COM>
I have the following variable (date) as below:
Date
-----
25Dec2006
02Jan2009
15Feb2009
18Nov2004
Now if I want to get only the day fom the above values and
want those values to a new varibale (Day) as below:
Day
---
25
02
15
18
Shoudl I use scan function to get the first two disgit? If
I do how?
Thanks for helping me
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and/or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.