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 (April 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 11 Apr 2008 17:04:52 -0700
Reply-To:   Daniel Nordlund <djnordlund@VERIZON.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Daniel Nordlund <djnordlund@VERIZON.NET>
Subject:   Re: how to deal with multiple ID
Comments:   To: AnoniDeer <irain168@GMAIL.COM>
In-Reply-To:   <3a237784-cd86-45d6-a20f-491e08221473@t54g2000hsg.googlegroups.com>
Content-type:   text/plain; charset=utf-8

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > AnoniDeer > Sent: Friday, April 11, 2008 4:44 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: how to deal with multiple ID > > I have a dataset like this.How could I get the difference between the > third and fourth observations for each of the group? for example for > the group 1 I need to get the difference for the observation of 45 and > 34. For the second group I need the difference of 76-34 and so on... > How to write a program to realize this? Thanks so much! >

I am assuming that your sample data faithfully represents what your data actually looks like: in sorted order, each group having exactly 4 observations. Something like this will work

data have; input group x; cards; 1 23 1 . 1 34 1 45 2 45 2 89 2 34 2 76 4 23 4 12 4 23 4 12 ; run;

data want ; set have; by group;

diff_34 = dif(x); if last.group then output; run;

If this doesn't meet your needs, write back to the list with more detail.

Hope this is helpful,

Dan

Daniel Nordlund Bothell, WA USA


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