LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 19 Feb 2008 11:54:14 -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: SAS date
Comments:   To: DP <adsingh78@GMAIL.COM>
In-Reply-To:   <200802191640.m1JBlnp8019125@malibu.cc.uga.edu>
Content-Type:   text/plain; charset="US-ASCII"

DP

Try the following:

data dp; infile cards missover;

informat ID $9. var1 date. var2 time.; input ID var1 var2 ; hour = hour(var2); minute = minute(var2); if hour = . then hour = 0 ; if minute = . then minute = 0; Date = dhms(var1,hour,minute,0); format date DATETIME20. ; cards; 018100009 05DEC2007 12:06 018100009 14DEC2007 018200086 08JAN2008 15:16 018200095 08JAN2008 12:10 018500019 10DEC2007 018500019 19DEC2007 10:03 018500020 10DEC2007 09:03 018500020 19DEC2007 09:08 018500021 09JAN2008 10:19 018500021 09JAN2008 10:19 run; Proc Print; run;

Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977

DP <adsingh78@GMAIL. COM> To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion" cc <SAS-L@LISTSERV.U GA.EDU> Subject SAS date

02/19/2008 11:40 AM

Please respond to DP <adsingh78@GMAIL. COM>

Hi,

I have a SAS date issue here. How can I do this in SAS. I have 2 situations here: 1. if only the date is available the new variable (VAR3) should be in the form of 11APR1999:00:00:00 (SAS DATETIME20. format)

2. if both date and time are available then new variable (VAR4) should be in this format 11APR1999:12:30:00 (SAS DATETIME20. format)

PS: VAR1 and VAR2 are character. DATA:

ID var1 var2

018100009 05DEC2007 12:06

018100009 14DEC2007

018200086 08JAN2008 15:16

018200095 08JAN2008 12:10

018500019 10DEC2007

018500019 19DEC2007 10:03

018500020 10DEC2007 09:03

018500020 19DEC2007 09:08

018500021 09JAN2008 10:19

018500021 09JAN2008 10:19

Thanks. DP

----------------------------------------- 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.


Back to: Top of message | Previous page | Main SAS-L page