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 (March 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 16 Mar 2009 12:18:14 -0400
Reply-To:     Akshaya <akshaya.nathilvar@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Akshaya <akshaya.nathilvar@GMAIL.COM>
Subject:      Re: How to collapse consecutive visits
Comments: To: Sophia Tong <sophiDT@hotmail.com>
In-Reply-To:  <200903161531.n2GAlHB3025992@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

Create 2 additional variables to indicate discharges happened in each Month of that Year. Retain the first admission and last discharge date of month/year and populate. Data have; input ID :$10. admit :mmddyy10. discharge :mmddyy10.; format _numeric_ mmddyy10.; _month=month(admit); _year=year(admit); cards; 90179392E 7/18/2007 7/18/2007 90256373a 9/7/2007 9/7/2007 90256373a 11/6/2007 11/6/2007 90256373a 11/7/2007 11/7/2007 90256373a 12/2/2007 12/2/2007 90256373a 12/3/2007 12/3/2007 90256373a 12/4/2007 12/4/2007 90256373a 12/5/2007 12/5/2007 90256373a 12/6/2007 12/6/2007 90256373a 12/7/2007 12/7/2007 90256373a 12/8/2007 12/8/2007 90256373a 4/10/2008 4/10/2008 90256373a 4/11/2008 4/11/2008 90256373a 4/12/2008 4/12/2008 90256373a 4/13/2008 4/13/2008 90256373a 4/14/2008 4/14/2008 90256373a 4/15/2008 4/15/2008 90256373a 4/16/2008 4/16/2008 90294928A 4/7/2008 4/7/2008 90294928A 4/7/2008 4/11/2008 90536782A 4/10/2008 4/10/2008 90536782A 4/11/2008 4/11/2008 90536782A 4/12/2008 4/12/2008 90536782A 4/13/2008 4/13/2008 90536782A 4/14/2008 4/14/2008 90536782A 4/15/2008 4/15/2008 90536782A 4/16/2008 4/16/2008 ;

Data want; do _n_=1 by 1 until(last._month); set have; by id _year _month; if first._month then ad=admit; dc=discharge; end;

do _n_=1 to _n_; set have; by id _year _month; if not first._month then do; ad=.; dc=.; end; output; end; drop _:; format _numeric_ mmddyy10.; Run;

On Mon, Mar 16, 2009 at 11:31 AM, Sophia Tong <sophiDT@hotmail.com> wrote:

> Dear listers, > > I have a admission - discharge data of patients. There are situations that > a patient had back to back admission - discharge, in that case, it should > count as one admission-discharge. I am truggling how to flag them out. > Below are the data I have and the outcome data I want. > > Thanks in advance, > > Sophia > > Data have: > ID admit discharge > 90179392E 7/18/2007 7/18/2007 > 90256373a 9/7/2007 9/7/2007 > 90256373a 11/6/2007 11/6/2007 > 90256373a 11/7/2007 11/7/2007 > 90256373a 12/2/2007 12/2/2007 > 90256373a 12/3/2007 12/3/2007 > 90256373a 12/4/2007 12/4/2007 > 90256373a 12/5/2007 12/5/2007 > 90256373a 12/6/2007 12/6/2007 > 90256373a 12/7/2007 12/7/2007 > 90256373a 12/8/2007 12/8/2007 > 90256373a 4/10/2008 4/10/2008 > 90256373a 4/11/2008 4/11/2008 > 90256373a 4/12/2008 4/12/2008 > 90256373a 4/13/2008 4/13/2008 > 90256373a 4/14/2008 4/14/2008 > 90256373a 4/15/2008 4/15/2008 > 90256373a 4/16/2008 4/16/2008 > 90294928A 4/7/2008 4/7/2008 > 90294928A 4/7/2008 4/11/2008 > 90536782A 4/10/2008 4/10/2008 > 90536782A 4/11/2008 4/11/2008 > 90536782A 4/12/2008 4/12/2008 > 90536782A 4/13/2008 4/13/2008 > 90536782A 4/14/2008 4/14/2008 > 90536782A 4/15/2008 4/15/2008 > 90536782A 4/16/2008 4/16/2008 > > data want: > > ID admit discharge AD DC > 90179392E 7/18/2007 7/18/2007 7/18/2007 7/18/2007 > 90256373a 9/7/2007 9/7/2007 9/7/2007 9/7/2007 > 90256373a 11/6/2007 11/6/2007 11/6/2007 11/7/2007 > 90256373a 11/7/2007 11/7/2007 > 90256373a 12/2/2007 12/2/2007 12/2/2007 12/8/2007 > 90256373a 12/3/2007 12/3/2007 > 90256373a 12/4/2007 12/4/2007 > 90256373a 12/5/2007 12/5/2007 > 90256373a 12/6/2007 12/6/2007 > 90256373a 12/7/2007 12/7/2007 > 90256373a 12/8/2007 12/8/2007 > 90256373a 4/10/2008 4/10/2008 4/10/2008 4/16/2008 > 90256373a 4/11/2008 4/11/2008 > 90256373a 4/12/2008 4/12/2008 > 90256373a 4/13/2008 4/13/2008 > 90256373a 4/14/2008 4/14/2008 > 90256373a 4/15/2008 4/15/2008 > 90256373a 4/16/2008 4/16/2008 > 90294928A 4/7/2008 4/7/2008 4/7/2008 4/11/2008 > 90294928A 4/7/2008 4/11/2008 > 90536782A 4/10/2008 4/10/2008 4/10/2008 4/16/2008 > 90536782A 4/11/2008 4/11/2008 > 90536782A 4/12/2008 4/12/2008 > 90536782A 4/13/2008 4/13/2008 > 90536782A 4/14/2008 4/14/2008 > 90536782A 4/15/2008 4/15/2008 > 90536782A 4/16/2008 4/16/2008 >

-- AkshayA!


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