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 2007, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 29 Mar 2007 14:42:00 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: Sum function with array elements
Comments: To: lmincieli@CHILDTRENDS.ORG
In-Reply-To:  <200703291418.l2TAkH8m015260@malibu.cc.uga.edu>
Content-Type: text/plain; format=flowed

Lisa ,

How you go about doing this largely depends on your data structure and your version of SAS. Otherwise we will be guessing and well the answers may not be as optimal as they could be.

Send both peices of information and a little sample data set and what you e[et the resulting data set to look like and I bet ya a dollar to a doughnut we can geter' done..

Toby Dunn

To sensible men, every day is a day of reckoning. ~John W. Gardner

The important thing is this: To be able at any moment to sacrifice that which we are for what we could become. ~Charles DuBois

Don't get your knickers in a knot. Nothing is solved and it just makes you walk funny. ~Kathryn Carpenter

From: Lisa <lmincieli@CHILDTRENDS.ORG> Reply-To: Lisa <lmincieli@CHILDTRENDS.ORG> To: SAS-L@LISTSERV.UGA.EDU Subject: Sum function with array elements Date: Thu, 29 Mar 2007 10:18:34 -0400

Hi all,

I am trying to create a series of 7 variables (one for each round of the survey data I am using) measuring how many rounds each respondent has been sexually active (totrndsact2-8). For example, if a respondent was sexually active in rounds 2,3,6,7 & 8 the new vars would be equal to the following: totrndsact2=1, totrndsact3=2, totrndsact4=2, totrndsact5=2, totrndsact6=3, totrndsact7=4, totrndsact8=5. Obviously, I can do this using the following code:

*R2*; totrndact2=sum(sexround2); *R3*; totrndact3=sum(sexround2,sexround3); *R4*; totrndact4=sum(sexround2, sexround3, sexround4); *R5*; totrndact5=sum(sexround2, sexround3, sexround4, sexround5); *R6*; totrndact6=sum(sexround2, sexround3, sexround4, sexround5, sexround6); *R7*; totrndact7=sum(sexround2, sexround3, sexround4, sexround5, sexround6, sexround7); *R8*; totrndact8=sum(sexround2, sexround3, sexround4, sexround5, sexround6, sexround7, sexround8);

However, I'd like to know how to do this within an array. I have tried several things, but am running into problems because the number of array elements to be summed changes for each value of totrndact. Any help would be appreciated. Thanks!

_________________________________________________________________ Exercise your brain! Try Flexicon. http://games.msn.com/en/flexicon/default.htm?icid=flexicon_hmemailtaglinemarch07


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