|
|||
|
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. |
|
|
||||
|
||||
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: A SCAN or INDEX or any other Function Question - VER VERY | Paul Dorfman | Newsgroup comp.soft-sys.sas | 0 | 10-08-2008 11:40 PM |
| Re: A SCAN or INDEX or any other Function Question - VER VERY | Pardee, Roy | Newsgroup comp.soft-sys.sas | 0 | 10-08-2008 11:38 PM |
| Re: SCAN function, default length 200, any rationale behind it? | Ed Heaton | Newsgroup comp.soft-sys.sas | 0 | 06-18-2008 08:06 PM |
| Re: A Function question | Nordlund, Dan | Newsgroup comp.soft-sys.sas | 0 | 06-06-2007 10:21 PM |
| Re: sorry,a stupid question about function | David L Cassell | Newsgroup comp.soft-sys.sas | 0 | 11-29-2005 05:35 AM |