Date: Fri, 14 Apr 2000 16:32:18 -0400
Reply-To: "Brucken, Nancy" <Nancy.Brucken@WL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Brucken, Nancy" <Nancy.Brucken@WL.COM>
Subject: Re: date and format programming issue
Content-Type: text/plain; charset="iso-8859-1"
Hi Yorgi,
Try this:
data temp1;
input record date yymmdd8. @14 alt yymmdd8.;
if date-alt >= 30 then newvar=1;
else newvar=0;
cards;
001 19970801 19960209
002 19970201 19960310
003 19961220 19951201
004 19970109 19971230
;
Then DATE and ALT are stored as SAS dates, and you can do the comparison.
Hope this helps,
Nancy
Nancy Brucken
Parke-Davis, Clinical Informatics
(734) 622-5767
E-mail address: Nancy.Brucken@wl.com
-----Original Message-----
From: yorgiv@MY-DEJA.COM [mailto:yorgiv@MY-DEJA.COM]
Sent: Friday, April 14, 2000 4:07 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: date and format programming issue
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.