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 (January 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 4 Jan 2007 10:56:09 -0500
Reply-To:   Jack Clark <JClark@CHPDM.UMBC.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jack Clark <JClark@CHPDM.UMBC.EDU>
Subject:   Re: Deleting all records for a policy:
Comments:   To: "Tramma, Patrick" <PTramma@GEICO.COM>
Content-Type:   text/plain

Patrick,

How about creating a new variable (d_max) that is the max(of d1-d3), then sorting the dataset by policy and descending d_max. That way if there is a true indicator in the policy - it will be reflected in the first observation for that policy. Then you can use the RETAIN and running indicator you were talking about.

Maybe a little long-winded, but here is an example...

data test; input P d1 d2 d3; d_max = max(of d1-d3); cards; 1 0 0 1 1 0 0 0 2 0 0 0 3 0 1 0 3 0 1 0 4 0 0 0 4 0 0 0 4 0 0 0 5 0 0 0 5 0 1 0 ; run;

proc sort data = test; by p descending d_max; run;

data test2; retain delete_flag; set test; by p; if first.p then do; delete_flag = 'N'; if d_max gt 0 then do; delete_flag = 'Y'; delete; end; end; else if delete_flag = 'Y' then delete; run;

Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tramma, Patrick Sent: Thursday, January 04, 2007 10:36 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Deleting all records for a policy:

I have a dataset with multiple rows per policy and indicators of whether or not I want to drop that policy. If any of the indicators are true, then drop the policy. If p were the policy number and d1-d3 were the drop codes, imagine a table like

P d1 d2 d3 1 0 0 1 1 0 0 0 2 0 0 0 3 0 1 0 3 0 1 0 4 0 0 0 4 0 0 0 4 0 0 0 5 0 0 0 5 0 1 0

I want to keep policies 2 and 4.

Ok, I know I can do this by creating a table of policy numbers to keep and then re-joining them back to the original, but I'd rather not use the space of another table. Using retain and a running indicator, you can delete subsequent rows, but not prior ones. (In other words, the problem I'm having is getting rid of the first row of policy 5 above.)

Any ideas?

Pat ==================== This email/fax message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution of this email/fax is prohibited. If you are not the intended recipient, please destroy all paper and electronic copies of the original message.


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