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 (September 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 2 Sep 2008 21:06:08 -0400
Reply-To:     Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Subject:      Re: counting comorbidities in a longitudinal dataset
In-Reply-To:  <2fc7f3340809021502k1cbffce1g369b19ddeeea628c@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Tue, Sep 2, 2008 at 6:02 PM, Muthia Kachirayan < muthia.kachirayan@gmail.com> wrote:

> > > On Tue, Sep 2, 2008 at 5:36 PM, Magda <magdatolea@yahoo.com> wrote: > >> I have a dataset that looks like: >> >> id visit diagnosis >> 1 1 ICD9 code >> 1 1 ICD9 code >> 1 2 ICD9 code >> 1 2 ICD9 code >> 1 2 ICD9 code >> 1 2 ICD9 code >> 2 1 ICD9 code >> >> etc .... >> >> I am only interested in counting the number of diagnoses per visit, >> assuming there are no duplicates within visits. In other words, I >> would like to have a dataset that looks like: >> >> id visit dx_no >> 1 1 2 >> 1 2 4 >> 2 1 1 >> >> I am sure there is a very easy way to come up with this, I just don't >> know enough SAS to do it. Your help will be very much appreciated. >> >> Thank you, >> Magda >> > > Under the stated assumptions, a datastep approach follows: > > data need; > do until(last.visit); > set have; > by id visit; > if first.visit then dx_no = 0; > dx_no + 1; > end; > drop diag; > run; > > > Still simpler. Assumed pre-sorted by id and visit and that diagnosis is unique within visit.

data need; retain id visit; do dx_no = 1 by 1 until(last.visit); set have; by id visit; end; drop diag:; run;


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