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 (November 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 2 Nov 2007 10:42:45 -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: Character date to Numeric value
Comments: To: Jake Bee <johbee@gmail.com>
In-Reply-To:  <ed52c9100711020834p5ee98ff4v5f8f7f2eea41980a@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

If you just want the datepart read the first 10 characters...

402 data _null_; 403 format rtsdtc1-rtsdtc2 date9.; 404 rfstdtc='2007-01-30T17:49:00'; 405 rtsdtc1=datepart(INPUT(rfstdtc,IS8601DT.)); 406 rtsdtc2=input(rfstdtc,yymmdd10.); ***; 407 put (_all_)(=); 408 run;

rtsdtc1=30JAN2007 rtsdtc2=30JAN2007 rfstdtc=2007-01-30T17:49:00

On 11/2/07, Jake Bee <johbee@gmail.com> wrote: > Isn't it like this? > > data dm; > format rtsdtc1 date9.; > rfstdtc='2007-01-30T17:49:00'; > rtsdtc1=datepart(INPUT(rfstdtc,IS8601DT.)); > run; > > proc print data=dm; > run; > > Jake > > > On 11/2/07, SAS_learner <proccontents@gmail.com> wrote: > > > > I am sorry guys I forgot to mention that I am still using SAS V 8 so I > > can't > > play with smart functions of 9 > > > > On 11/2/07, ckxplus@yahoo.com <ckxplus@yahoo.com> wrote: > > > > > > Try the anydt* informats. Here's an example: > > > > > > data null; > > > length datestring $20; > > > datestring='2007-01-30T17:49:00'; > > > put datestring; > > > > > > dt=input(datestring,anydtdte21.); > > > put dt date9.; > > > > > > datetime=input(datestring,ANYDTDTM21.); > > > put datetime datetime.; > > > > > > dateprt=datepart(datetime); > > > put dateprt ddmmyy10.; > > > > > > run; > > > > > > Results: > > > 2007-01-30T17:49:00 > > > 30JAN2007 > > > 30JAN07:17:49:00 > > > 30/01/2007 > > > > > > Good luck, > > > John Hendrickx > > > > > > On 2 nov, 14:52, procconte...@GMAIL.COM (SAS_learner) wrote: > > > > Hello All, > > > > > > > > I have date (ISO 8601 standard For Ex : 2007-01-30T17:49:00 ) I am > > > trying > > > > to convert it to numeric date, I checked every where for an informat > > to > > > > convert it into sas Numerical date like this ; > > > > > > > > Data Dm ; > > > > Set Mntx3301.Dm; > > > > RFSDTC1 = Input( RFSTDTC , is8601dt. ) ; > > > > Keep Usubjid subjid siteid RFSTDTC RFENDTC RFSTDTC1 ; > > > > Run; > > > > > > > > This is giving me an error, > > > > Then I thought of cutting it and putting it way the SAS likes > > > > > > > > RFSDTC1 > > > > > > > > > =input(compress(put(scan(RFSDTC,2,'-'),$2.)||put(scan(RFSDTC,3,'-'),$2.)||p­ut(scan(RFSDTC,1,'-'),$4.)),mmddyy8.); > > > > > > > > but is there a better way than this to do this., While converting this > > > way I > > > > would be ignoring the time part right so should I need to use > > > datetime20. to > > > > change exactly for character to Numeric. > > > > > > > > thank you all for the help > > > > > >


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