Date: Mon, 9 Jul 2007 08:10:06 -0400
Reply-To: "V. Bourcier" <veronique.bourcier@LAPOSTE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "V. Bourcier" <veronique.bourcier@LAPOSTE.NET>
Subject: Re: A QUESTION ABOUT SAS DATE TIME.
Thanks a lot for this usefull explainationg. I've taken it into account to
get data set three.
data three;
informat y nd8601tm.;
format y time5.;
input y;
datalines;
1130
;
run;
proc print data=three;
run;
Best Regards,
Veronique
>The statement "Informat ... ;" in Data TWO assigns an attribute to the
>column Y. This means if something is read into this column from an
external
>data source like an infile, or a cards statement, then the informat will
>perform the transition from input text to stored value. Since you have
done
>an assignment to Y in the next line, there is no transition from an
external
>source and the value is simply assigned to the numeric column.
>
>In Data ONE, you have a string value in quotes, and use the informat to
read
>the external value, so the informat is used to make the change.
>
>Thus Data ONE will have 11:30 as a time value, underlying which will be a
>value which is the number of seconds 11:30 is past midnight (11 * 3600 +
>1800). And Data TWO will have a value which is 1130 seconds past midnight.
>Since there are 3600 seconds in an hour, it will be around 20 minutes past
>midnight.
>
>Kind regards
>
>David
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of V.
>Bourcier
>Sent: Monday, 9 July 2007 7:40 PM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: A QUESTION ABOUT SAS DATE TIME.
>
>
>Hi,
>
>I've used the code suggested above and I am trying to figure out why data
>set two does not print the save as data set one.
>
>
>data one;
> y=input('1130',nd8601tm.);
> format y time5.;
>run;
>
>proc print data=one;
>run;
>
>data two;
> informat y nd8601tm.;
> y=1130;
> format y time5.;
>run;
>
>proc print data=two;
>run;
>
>
>Best Regards
>
>Veronique
>
>>>>I have following Character variable:
>>>>
>>>>C_time
>>>>-------
>>>>1130
>>>>1230
>>>>0945
>>>>
>>>>need the following numeric variable output:
>>>>
>>>>C_Time
>>>>------
>>>>11:30
>>>>12:30
>>>>09:45
>>>>
>>>>
>>>>Now I have the following to numeric variables:
>>>>
>>>>Date C_Time
>>>>--------- -------
>>>>23DEC2005 11:30
>>>>27DEC2007 12:30
>>>>
>>>>Need a output using DHMS fuction to get a SAS datetime value.
>>>>
>>>>Thanks for your help.
>>>
>>>Try this:
>>>
>>> data have;
>>> input Date : date9. C_time : $4.;
>>> format date date9.;
>>> datalines;
>>> 23DEC2005 1130
>>> 27DEC2007 1230
>>> . 0945
>>> run;
>>>
>>> proc sql;
>>> create table need as
>>> select date
>>> , input ( C_time , ND8601TM. )
>>> as C_Time format=time5.
>>> , dhms ( date , 0, 0 , calculated c_time )
>>> as MyDateTime format=datetime19.
>>> from have;
>>> quit;
>>>
>>>Result:
>>>
>>> Date C_Time MyDateTime
>>>
>>> 23DEC2005 11:30 23DEC2005:11:30:00
>>> 27DEC2007 12:30 27DEC2007:12:30:00
>>> . 9:45 .
>>
>>Also see
>>
>>http://sascommunity.org/wiki/Time_Informats
|