Date: Fri, 29 Apr 2005 14:07:54 -0400
Reply-To: harry.droogendyk@RBC.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Harry Droogendyk <harry.droogendyk@RBC.COM>
Subject: Re: Sum
Content-Type: text/plain; charset="iso-8859-1"
This is starting to look like homework questions...
You've started well, breaking it into chunks, why don't you try to solve this the same way, do 1, then 2 etc..
See OnlineDocs, http://v8doc.sas.com/sashtml/, for:
array: eg. array x x: ;
do; loop for cycling through the array items
if then/else for examining values of the array buckets
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of
Thomas
Sent: Friday, April 29, 2005 1:58 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Sum
Hi all,
May I know how to sum the following variables and then do the average
across it? The -999 and . should be excluded from the summing and
averaging.
Thank you very much!
Procedures:
1. sum across x and y separately.
2. each individual x divided by sum_x from No.1 (each individual y divided
by sum_y).
3. square each individual from the NO.2
4. sum again the No.3 across x and y, respectively.
4. -999 and . are excluded here (treated as missing values).
/*expected data*/
id x1 x2 x3 x4 y1 y2 y3 y4 y5
1 100 50 -999 . 20 22 23 25 30
2 -999 0 40 -999 . -999 40 -999 .
3 100 . -999 . 50 0 . . -999
/*expected output */
id index_x index_y;
1 0.5556 [(100/150)^2] + [(50/150)^2] 0.204 [the cal. same as var x]
2 1 [(0/40)^2] + [(40/40)^2 1
3 1 (100/100)^2 1
__________________________________________________________________________________________________________________________________
This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.
Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite.
Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.