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 (February 1996, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 15 Feb 1996 21:02:36 -0500
Reply-To:     Frank Schnekenburger <schnekf@GOV.ON.CA>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Frank Schnekenburger <schnekf@GOV.ON.CA>
Organization: Ministry of Natural Resources
Subject:      Re: Convert group of records ==> single big record ??

stow@skyfox.usask.ca wrote:

> > I have a data set (hospital admission data) with any where from 1 to 37 > records per person. > > Common: Fields: IDNumber, BirthD > Distinct fields: DoAdmiss (Date of admission) > DoDis (Date of discharge) > {Several others that can be ignored for this discussion.} > > I have sorted the data set by IDNumber, DoAdmiss, DoDis. > > I would like to make a new data set that looks at all of the records for > a person and takes all of those that occupy a continuous sequence of days > (ie, if IDNumber for records n and n+1 are the same and > DoDis for record n is the same as or one day earlier than > the DoAdmiss for record n+1

Hello,

I think the following code will do what you want:

%let maxadm=4; /* max number of admissions in an episode */

data temp; input idnum birthd doadmiss dodisc; cards; 23 191212 900607 900607 123 191212 900607 900607 123 191212 900607 900609 123 191212 900610 900611 123 191212 900613 900615 123 191212 900617 900618 123 191212 900619 900623 123 191212 900624 900628 223 191212 900607 900607 223 191212 900607 900609 223 191212 900610 900611 223 191212 900613 900615 223 191212 900617 900618 223 191212 900619 900623 223 191212 900626 900628 ;

data test; keep idnum birthd doadm1-doadm&maxadm dodis1-dodis&maxadm;

array doadm{&maxadm}; array dodis{&maxadm}; retain admiss lastdate; retain doadm1-doadm&maxadm dodis1-dodis&maxadm;

set temp; by idnum; /* data must be sorted by idnum */

if first.idnum then do; admiss = 1; end; else if doadmiss=lastdate or doadmiss-1=lastdate then do; admiss = admiss + 1; end; else do; output; admiss = 1; do i = 1 to &maxadm; /* reset record */ doadm{i}=.; dodis{i}=.; end; end;

doadm{admiss}=doadmiss; dodis{admiss}=dodisc; lastdate=dodisc;

if last.idnum then output;

run;

Hope this helps;

Frank;

--

Frank Schnekenburger ++ When I grow up I want to be a Tree Improvement Data Analyst ++ Third Stage Guild Navigator. Minstry of Natural Resources ++ ----------------------------- schnekf@gov.on.ca ++ lI' veQ, lab veQ


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