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 (July 2003, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 7 Jul 2003 09:43:47 -0700
Reply-To:     "Huang, Ya" <yhuang@AMYLIN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Huang, Ya" <yhuang@AMYLIN.COM>
Subject:      Re: Selecting Obs.
Comments: To: Franz <franz_cl2003@YAHOO.FR>
Content-Type: text/plain; charset="iso-8859-1"

How about sql?

DATA clinic; INPUT subid 3. l_intake ddmmyy10. visit_dt ddmmyy10.; FORMAT l_intake visit_dt date9.; CARDS; 001 01062003 12062003 001 01062003 14062003 001 01062003 20062003 002 01052003 09052003 002 01052003 16052003 003 05052003 13052003 ; RUN;

proc sql; select * from clinic group by subid having abs(l_intake+13-visit_dt)=min(abs(l_intake+13-visit_dt)) ; ------------------- subid l_intake visit_dt ffffffffffffffffffffffffffffff 1 01JUN2003 14JUN2003 2 01MAY2003 16MAY2003 3 05MAY2003 13MAY2003

If there is a tie, it will pick up both of them, if you can define a rule for breaking up the tie, I may try to add something in the code.

Kind regards,

Ya Huang

-----Original Message----- From: Franz [mailto:franz_cl2003@YAHOO.FR] Sent: Monday, July 07, 2003 9:27 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Selecting Obs.

Dear all,

I have the following situation:

DATA clinic; INPUT subid 3. l_intake ddmmyy10. visit_dt ddmmyy10.; FORMAT l_intake visit_dt date9.; CARDS; 001 01062003 12062003 001 01062003 14062003 001 01062003 20062003 002 01052003 09052003 002 01052003 16052003 003 05052003 13052003 ; RUN;

Out of the previous dataset (clinic) I would like to select only one observation per subid according to the following conditions:

* If the the patient have only one observation then this Observation must be selected. * If he has more than one observation (the case with subid 001 and 002) then I must select the observation where the visit date (visit_dt) is much closer to the last intake date +14 (l_intake +14)

This means, my final dataset should only have these 3 observations.

001 01062003 14062003 002 01052003 16052003 003 05052003 13052003

Thank you very much! Regards, Franz.

__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com


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