LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 14 Apr 2000 16:54:18 EDT
Reply-To:     Bernard Tremblay <imaginasys@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Bernard Tremblay <imaginasys@HOTMAIL.COM>
Subject:      Re: date and format programming issue
Comments: To: yorgiv@MY-DEJA.COM
Content-Type: text/plain; charset=iso-8859-1; format=flowed

Hi Yorgi,

Try this:

data f1; input @2 record $3. @6 date yymmdd8. @15 alt yymmdd8.; format date alt yymmdd8. ; day30 = (date - alt) >= 30; cards; 001 19970801 19960209 002 19970201 19960310 003 19961220 19951201 004 19970109 19971230 ; run;

Explications: You have to work with "SAS dates" not ordinary numeric nor character variable to utilise the FORCE of SAS! The SAS date is kept internaly as the number of days since 01jan1960. When you substract two dates you get the number of days between the 2 dates. That's why the flag "day30" will resolve to 1 if the difference between the dates is greater or equal 30 days.

Good luck and happy SAS'ing,

Bernard Tremblay Imaginasys enr. imaginasys@hotmail.com B: Bernard.Tremblay@csst.qc.ca (418)644-4113 R: bertrem@quebectel.com (418)658-1411

>From: yorgiv@MY-DEJA.COM >Reply-To: yorgiv@MY-DEJA.COM >To: SAS-L@LISTSERV.UGA.EDU >Subject: date and format programming issue >Date: Fri, 14 Apr 2000 20:06:30 GMT > >Hi, > >I have a SAS data set with 2 date fields in this format >yyyymmdd. Using SAS 6.12 I need to compare the dates >in this file such that if date is 30 days or more after alt >then new variable obtains value of 1 otherwise 0. > >data temp1; >input record date alt; >cards; >001 19970801 19960209 >002 19970201 19960310 >003 19961220 19951201 >004 19970109 19971230 >; > >I cannot perform a mathematical operation with yyyymmdd8. format >(SAS 6.12 does not recoginse it I think). So I substring data: > >data temp1; >set temp1; > date2=substr(date,7,6); >proc print; >run; >data temp1; >set temp1; > alt2=substr(alt,16,6); >proc print; >run; > >Returns: > >OBS RECORD DATE ALT DATE2 ALT2 >1 1 19970801 19980209 970801 19 >2 2 19970201 19960310 970201 19 >3 3 19961220 19951201 961220 19 >4 4 19970109 19961230 970109 19 > >I don't know why it does this. And I am very frustrated. Can >anyone help me please? > >Yorgi V. > > >Sent via Deja.com http://www.deja.com/ >Before you buy.

______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com


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