Date: Tue, 13 Mar 2007 12:17:08 -0700
Reply-To: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject: Re: How to Fill in the missing dates ??
In-Reply-To: A<c2192a610703131132t113b010dme3b08405ddd47c90@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"
Hi,
I checked with SAS_Learner offline
and the criteria is the inbetween
dates...
Here is one approach:
data sample;
infile cards missover;
input PT $6. visdtn mmddyy10. diff_vis;
format visdtn mmddyy10.;
cards;
001001 3/17/2006
001001 3/27/2006 10
001001
001001 4/10/2006 14
001001
001001
001001 4/25/2006 15
001001
001001 5/19/2006 24
001001
001001
001001 6/16/2006 28
001001
001001 7/27/2006 41
001001
001001 8/18/2006 22
001001 9/11/2006 24
;
run;
* the inbetween dates ;
data result(keep=PT visdtn);
set sample;
by PT;
retain last_date .;
if first.PT then
do;
last_date = visdtn;
end;
else if visdtn ne . then
do;
hold_date = visdtn;
do visdtn = (last_date+1) to (hold_date-1);
output;
end;
last_date = hold_date;
end;
run;
Hope this is helpful.
Mark Terjeson
Senior Programmer Analyst, IM&R
Russell Investment Group
Russell
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
SAS_learner
Sent: Tuesday, March 13, 2007 11:32 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: How to Fill in the missing dates ??
hello guys,
I have a dateset something like this
PT visdtn diff_vis 001001 3/17/2006 001001
3/27/2006
10 001001 001001 4/10/2006 14 001001 001001 001001 4/25/2006 15
001001
001001 5/19/2006 24 001001 001001 001001 6/16/2006 28 001001 001001
7/27/2006 41 001001 001001 8/18/2006 22 001001 9/11/2006 24
Now I need a dataset that has missing dates between visdtn i.e. I need
to
add an record for each date inbetween the visitdates for this pt
keeping in
mind about the number of days in a month ( either 30 days or 31 days )
and
when year changes I need to keep track of leap year . Can any body has
an
Idea how to do it
I want my final dataset look like this
001001 3/17/2006 001001 3/18/2006 001001 3/19/2006 001001
3/20/2006
001001 3/21/2006 001001 3/22/2006 001001 3/22/2006 001001 3/23/2006
001001 3/24/2006 001001 3/25/2006 001001 3/26/2006
as I have 17th and 27th