Date: Tue, 4 Aug 1998 21:48:27 +0100
Reply-To: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Subject: Re: Character to date (Thanks)
In-Reply-To: <902257912.203095.0@vm121.akh-wien.ac.at>
In article <902257912.203095.0@vm121.akh-wien.ac.at>, Gene Huang <Chin-
JenHuang@FIRSTUSA.COM> writes
>try this
>
>y=put(substr(yyyymmdd,1,4),4.);
>m=put(substr(yyyymmdd,5,2),2.);
>d=put(substr(yyyymmdd,7,2),2.);
>day=mdy(m,d,y)-date();
>
>> -----Original Message-----
>> From: abdu.elnagheeb(a)nationsbank.com
>> [SMTP:abdu.elnagheeb@NATIONSBANK.COM]
>> Sent: Tuesday, August 04, 1998 11:47 AM
>> To: SAS-L@UGA.CC.UGA.EDU
>> Subject: Re: Character to date (Thanks)
>>
>> First, thanks to all who responded to me privately or on the
>> list.
>> Very helpful answers (though diverse.) Just FYI, the way I
>> approached
>> it was:
>> NewYr = Substr(My yyyymmdd Varible,3,2) ;
>> NewMo = Substr(My yyyymmdd Varible,5,2) ;
>> NewDy = Substr(My yyyymmdd Varible,7,2) ;
>> ***days since yyyymmdd upto 8/4/98*****;
>> Days = 365*(98 - NewYr) + 30*(8 - NewMo) + (4 - NewDy) ;
>>
>> I thought there ought to be a more efficient way as your messages
>> proved that. I'm not sure which one will be more accurate (with
>> some
>> months 28,29,30,or 31 days.)
>>
>> Abdu
>>
>> >>>>>>>>>>>>>
>> Hello all,
>> I hope someone will help me woth this.
>> I have a variable which is character of the form yyyymmdd where
>> yyyy
>> is the year, mm is the month and dd is the day (e.g. 19970603 for
>> June
>> 3, 1997.) I want to calculate the time between that date and
>> today's
>> date. What is the best way to do that? How to convert that
>> character
>> variable to date of the form yymmdd (or other format: ddmmyy)?
>> Thanks for your help.
>>
>> abdu
Excuse me, but is there a problem stopping the use of yymmdd8. informat?
For example...
27 data a;
28 input c $8. ; /*could input into a date, but you have text*/
29 d = input( c, yymmdd8. ); /*so, using the input function*/
30 gap = date() - d; /* to convert text to SASdate*/
31 put _all_;
32 format d date9.;
33 cards;
C=19980228 D=28FEB1998 GAP=157 _ERROR_=0 _N_=1
C=19960229 D=29FEB1996 GAP=887 _ERROR_=0 _N_=2
C=20000229 D=29FEB2000 GAP=-574 _ERROR_=0 _N_=3
--
Peter Crawford
|