Date: Fri, 3 Nov 2006 11:31:24 -0500
Reply-To: "data _null_;" <datanull@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "data _null_;" <datanull@GMAIL.COM>
Subject: Re: How to add 6 hrs to date and time field
In-Reply-To: <OF29491ECA.4BD8B883-ON8525721B.0058A01D-8525721B.0059AB09@dom.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
How about DATETIME20.;
length dosedtm5 $15;
dosedtm5=put(value,datetime20.-l);
No insertion required.
On 11/3/06, Nat Wooding <Nathaniel_Wooding@dom.com> wrote:
> Suthakar
>
> Since you say that the variable is stored as $15 , you first have to create
> a new variable that is a SAS date time value which is stored a the number
> of seconds since Jan 1, 1960. You then add the number of seconds in 6 hours
> to this (I show this as a product below while you would want to enter the
> actual value) and hen this should be written to the new variable using a
> put statement. Do note that the value that the datetime format produces
> does not include the century. If you want the century, you will need to
> stick the century in the new variable as I did below.
>
> Nat Wooding
>
> data ;
>
> dosedtm3='09OCT2006:21:09';
>
> value=input(dosedtm3,datetime.) +6*60*60;
>
> format value datetime14. ;
> dosedtm4=left(put(value,datetime14.));
> str1=substr(dosedtm4,1,5);
> str2=substr(dosedtm4,6);
> dosedtm4=compress(str1||'20'||str2);
> *
> drop str: value;
> proc print;run;
>
>
>
>
>
>
> Suthakar Iyer
> <suthakariyer@YAH
> OO.COM> To
> Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU
> Discussion" cc
> <SAS-L@LISTSERV.U
> GA.EDU> Subject
> How to add 6 hrs to date and time
> field
> 11/03/2006 10:49
> AM
>
>
> Please respond to
> Suthakar Iyer
> <suthakariyer@YAH
> OO.COM>
>
>
>
>
>
>
> Hi,
> My dataset looks like this :
>
> Patno Cno dosedtm1 dosedtm2 dosedtm3
> 10001 12 09OCT2006:09:03 09OCT2006:15:09 09OCT2006:21:09
>
> I want to create a variable dosedtm4 which is 6 hrs added to dosedtm3
> that is (dosedtm3 + 6 hrs) .
>
> The dosedtm3 is a variable type $15.
>
> Thanks for your help.
> Suthakar
>
>
>
>
>
> ---------------------------------
> Check out the New Yahoo! Mail - Fire up a more powerful email and get
> things done faster.
>
>
>
> -----------------------------------------
> 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.
>
|