Date: Tue, 6 Dec 2005 15:55:01 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: Eliminating rows, based on date values
In-Reply-To: <200512061551.jB6EsDVx020379@mailgw.cc.uga.edu>
Content-Type: text/plain; format=flowed
Jim,
I thought it was 30 days but it seems I miss read it should be 90 days.
As for the code I must be having a bad day your right there too my man:
LastDate = Lag(SASDate) ;
If not first.Var_a then do ;
if ( ( SASDate - LastDate ) < 90 ) then delete ;
end ;
Should fix the problem.
Now with those screw ups out of the way I am going to go over here and sit
quitely on my corner...before I make anymore screw ups today.
Toby Dunn
From: Jim Groeneveld <jim1stat@YAHOO.CO.UK>
To: SAS-L@LISTSERV.UGA.EDU, Toby Dunn <tobydunn@HOTMAIL.COM>
Subject: Re: Eliminating rows, based on date values
Date: Tue, 6 Dec 2005 10:51:24 -0500
Hi Toby,
Good idea, but shouldn't 30 be 90 as Tomas requested?
And very important: do not use the LAG function conditionally!
Calculate the LAG initially ouside the IF block!
Regards - Jim.
--
Y. (Jim) Groeneveld, MSc., Biostatistician, Vitatron b.v., NL
Jim.Groeneveld_AT_Vitatron.com (replace _AT_ by AT sign)
http://www.vitatron.com, http://home.hccnet.nl/jim.groeneveld
My computer regards me as its master, but I seem to be its slave.
[common disclaimer]
On Tue, 6 Dec 2005 15:44:18 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote:
>Tomas,
>
>Try something like:
>
>If not first.Var_a then do ;
> if ( SASDate - Lag(SASDate) ) < 30 then delete ;
>end ;
>
>Essentually SAS date values are scalers, where they measure the number of
>days from january 1, 1960. So provided you have the dates in SAS Date
Value
>Form Which it looks like you do, then all you need to do is get the last
>data value and then substract, if that is less than 30 then delete.
>The do loop is designed so that you dont do this comparison on the first
>obeservation of a new Var_a Group.
>
>Toby Dunn
>
>
>
>
>
>From: Tomas <tomas.corveleyn@GMAIL.COM>
>Reply-To: Tomas <tomas.corveleyn@GMAIL.COM>
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Eliminating rows, based on date values
>Date: Tue, 6 Dec 2005 07:29:28 -0800
>
>
>Dear,
>
>I'm trying desperately to eliminate rows from the following type of
>file:
>
>obs var_a Date Sasvalue(date)
> 1 1 2/apr/02 15432
> 2 1 12/jun/03 15868
> 3 1 13/jun/03 15869
> 4 1 14/jun/03 15870
> 5 1 15/jun/03 15871
> 6 1 16/jun/03 15872
> 7 2 26/mar/02 15425
> 8 2 11/sep/03 15959
> 9 3 1/jan/03 15706
>
>With var_a being the id for a person. Based on the variable "Date" or
>the Sasvalue of that variable, I want to eliminate observations 3 to 6.
>I do not want to end up with only one observation per person, I want to
>keep the observations between which there are at least 90 days! So, my
>end-file has to be the following:
>
>obs var_a Date Sasvalue(date)
> 1 1 2/apr/02 15432
> 2 1 12/jun/03 15868
> 7 2 26/mar/02 15425
> 8 2 11/sep/03 15959
> 9 3 1/jan/03 15706
>
>I've tried "retain" statements working on the Sasvalue of the
>datevariable, but I haven't been able to compute the correct formula
>which eliminates only observations 3 to 6. Or I eliminate to much, or I
>eliminate to little. Can someone help me with this problem?
>
>Many thanks,
>
>Tomas Corveleyn.
|