Date: Wed, 8 Jul 2009 15:34:05 -0400
Reply-To: "Kirby, Ted" <ted.kirby@LEWIN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Kirby, Ted" <ted.kirby@LEWIN.COM>
Subject: Re: need helps for the Index problem
In-Reply-To: A<941871A13165C2418EC144ACB212BDB0BEB444@dshsmxoly1504g.dshs.wa.lcl>
Content-Type: text/plain; charset="us-ascii"
That is much more elegant that my solution, which used 3 DATA steps and
a PROC SUMMARY.
Thank you, Dan for the streamlined code. I am relatively new to PROC
SQL (and I have not used any other SQL) so it is fun to see PROC SQL
used in ways that I did not know it could be used.
--Ted Kirby,
Consultant,
The Lewin Group, Inc.
3130 Faivew Park Drive, Suite 800
Falls Church, VA 22042
e-mail: ted.kirby@lewin.com
P: (703)269-5507
F: (703)269-5501
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Nordlund, Dan (DSHS/RDA)
Sent: Wednesday, July 08, 2009 2:44 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: need helps for the Index problem
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> oslo
> Sent: Wednesday, July 08, 2009 11:19 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: need helps for the Index problem
>
> Joe;
>
> Thanks for writing. I am sorry I could not explain the problem
> clearly. I have a data set has 5600 length. I would like calculate new
> indexes from variable y at the first column. For example
>
> 0.2+0.4+0.6+0.1 y1+y2+y3+y4
> index1= ---------------------------- = -------------------------
> Total (sum of y) sum of y
>
> y5+y6+y7+y8
> index2= ----------------------------
> sum of y
>
> y9+y10+y11+y12
> index3= ----------------------------
> sum of y
>
> and other indexes for the each consecutive 4 variables should be
> calculated this fashion.
>
> data a;
> input y trt;
> cards
> 0.2 1
> 0.4 1
> 0.6 1
> 0.1 1
> 0.4 2
> 0.5 2
> 0.8 2
> 0.5 2
> 0.3 3
> 0.2 3
> 0.1 3
> 0.6 3
> . .
> .
>
>
>
Here is one solution:
proc sql noprint;
select sum(y) into: total
from a
;
create table want as
select trt, sum(y)/&total as index
from a
group by trt
;
quit;
Hope this is helpful,
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services Planning,
Performance, and Accountability Research and Data Analysis Division
Olympia, WA 98504-5204
************* IMPORTANT - PLEASE READ ********************
This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately.
|