[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: please help
From:       Joe Matise <snoopy369 () GMAIL ! COM>
Date:       2009-09-07 14:18:33
Message-ID: b7a7fa630909070718v2783c08x877780f0d1b68080 () mail ! gmail ! com
[Download RAW message or body]

Assuming data have; (your data); run; then:
proc sort data=have; by pid date; run;

data want;
 set have;
 by pid date;
 retain visit;
 if first.pid then visit=1;
 else visit+1;
run;

-Joe

On Mon, Sep 7, 2009 at 9:13 AM, evallyne sikuku <esimuli@live.com> wrote:

> Hi all,
>
> I need some help
>
> How can I automatically generate a count for the visits of patients coming
> to the clinic where every visit per patient will have visit number.
>
> If my data looks like this;
>
> current data
>
>
>
>
>
>
>
> pid
> date
>
> 1
> 1/1/2009
>
> 1
> 2/1/2009
>
> 1
> 4/2/2009
>
> 1
> 28/3/2009
>
> 2
> 4/6/2008
>
> 2
> 3/1/2009
>
> 2
> 4/2/2009
>
> 3
> 14/1/2009
>
> 3
> 20/3/2009
>
>
>
> and I want the new data to have the visit_count as follow
>
>
>
>
>
>
>
> pid
> date
> visit_count
>
> 1
> 1/1/2009
> 1
>
> 1
> 2/1/2009
> 2
>
> 1
> 4/2/2009
> 3
>
> 1
> 28/3/2009
> 4
>
> 2
> 4/6/2008
> 1
>
> 2
> 3/1/2009
> 2
>
> 2
> 4/2/2009
> 3
>
> 3
> 14/1/2009
> 1
>
> 3
> 20/3/2009
> 2
>
>
>
> Thanks guys
>
> Eva
>
>
>
>
>
>
>
> _________________________________________________________________
> With Windows Live, you can organize, edit, and share your photos.
>
> http://www.microsoft.com/middleeast/windows/windowslive/products/photo-gallery-edit.aspx
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic