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 (January 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 27 Jan 2005 20:10:46 -0600
Reply-To:     Robin High <robinh@UNLSERVE.UNL.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Robin High <robinh@UNLSERVE.UNL.EDU>
Subject:      Re: Summing across records
Comments: To: seema.pai@GMAIL.COM
In-Reply-To:  <1106876066.926371.278630@f14g2000cwb.googlegroups.com>
Content-Type: TEXT/PLAIN; charset=US-ASCII

> > I have a dataset where I have multiple observations per respondent > identified by the respondent id. I need to sum one of the variables in > my dataset across all the records for a particular respondent to create > a summary dataset. > > For instance > > id var1 var2 var3 > 1 > 1 > 1 > 1 > 2 > 2 > 3 > 3 > 3 > 3 > 3 > > I want to create a new dataset that has the following format > > id varsum1 > 1 > 2 > 3 > 4 > > where varsum1 = sum of var1 for all observations for that particular > id.

Seema,

Proc MEANS is one method:

PROC SORT DATA = your_data; *assuming data needs to be sorted; BY id;

PROC MEANS DATA = your_data noPrint; BY id; VAR var1 var2 var3; OUTPUT OUT=sum_var sum=varsum1 varsum2 varsum3; Run;

Robin High Univ. of Oregon


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